Skip to content

matchByName() breaks when name contains a '.' #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sithy opened this issue Mar 14, 2011 · 1 comment
Open

matchByName() breaks when name contains a '.' #25

sithy opened this issue Mar 14, 2011 · 1 comment

Comments

@sithy
Copy link

sithy commented Mar 14, 2011

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));
    }
@D1g1talEntr0py
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants