Skip to content
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

Names with multiple brackets are truncated #36

Closed
marosluuce opened this issue Sep 4, 2014 · 6 comments
Closed

Names with multiple brackets are truncated #36

marosluuce opened this issue Sep 4, 2014 · 6 comments

Comments

@marosluuce
Copy link

Ran into a situation where doing affix('input[name="some[thing][foo]"]') gets turned into <input name="some[thing][foo"></input>. None of the tests fail when I add it as a test case though. It seems like it might be a problem with the regular expressions only expecting one set of brackets inside a name. I haven't been able to track down the specific problem yet though.

@searls
Copy link
Owner

searls commented Sep 4, 2014

Hey @marosluuce!

This strikes me as very believable, as it was thanks to a PR quite some time ago to even add support for a single pair of brackets in an attribute. This is most commonly necessary when you're testing some JS that's going to interact with a form generated by Rails using nested form fields, right?

@marosluuce
Copy link
Author

That's exactly correct.

@marosluuce
Copy link
Author

That said, I'm working around the problem by wrapping affix in a function to set the names I want to use.

@searls
Copy link
Owner

searls commented Sep 4, 2014

In cases like this I would recommend some indirection between your JavaScript and the names that you don't control (e.g. Rails 5 could theoretically change to stop using [] in input names and all your custom selectors would break). In cases like this I normally stick a class on them from my template or select them in my JS some other way.

That said if you do take the time to add a failing test and fix the regex, that'd be great, since, you know, I'd love jasmine-fixture to actually work.

@marosluuce
Copy link
Author

Yeah, unfortunately decisions I can't control necessitate the use of the name of the element.

It's going to be tricky to add a failing test because the actual and expected values match. If I do get around to it, I'll submit a pull request.

@kchien kchien mentioned this issue Sep 20, 2014
@kchien
Copy link
Contributor

kchien commented Oct 28, 2014

@searls This issue should be closed since issue #39 fixed the problem.

@searls searls closed this as completed Oct 28, 2014
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

3 participants