jquery-datalink icon indicating copy to clipboard operation
jquery-datalink copied to clipboard

matchByName() breaks when name contains a '.'

Open sithy opened this issue 13 years ago • 1 comments

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));
    }

sithy avatar Mar 14 '11 17:03 sithy

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 +"\"]";

D1g1talEntr0py avatar Sep 13 '11 13:09 D1g1talEntr0py