jquery-datalink
jquery-datalink copied to clipboard
matchByName() breaks when name contains a '.'
Using jQuery 1.5.1 I encountered an issue with data link when my input names had dots inside the name. The exception that Chrome was throwing was from sizzle 'Uncaught Syntax error, unrecognized expression: [name=Domain.BusinessRelationship]'
I believe I found the issue and the fix, inside matchByName there are no single quotes around the name element, adding those in the error goes away and the link works as expected.
function matchByName(name) {
var selector = "[name='" + name + "'], [id='" + name +"']";
// include elements in this set that match as well a child matches
return self.filter(selector).add(self.find(selector));
}
Escape the selector with ". This will fix the issue. The quotes should always be there when using attribute selectors.
var selector = "[name=\"" + name + "\"], [id=\"" + name +"\"]";