-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Manipulation: Bring tagname regexes up to spec #2634
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
Conversation
|
You have to exclude NULL ( |
983af84 to
381d4b2
Compare
|
@mzgol Added the missing NULL ( |
381d4b2 to
3f4e917
Compare
src/core/var/rsingleTag.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments on this regular expression:
\sis too broad—we should instead use\x20\t\r\n\f(assuming Recognize carriage return as a tag name terminator whatwg/html#242 is accepted)- It shouldn't start accepting
:, which is special in XHTML—such text should go through the namespace-awareinnerHTMLpath - It would be smaller if it were case-insensitive rather than explicitly matching
A-Z. Altogether, I got good results with/^<([a-z][^:\/\0>\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I'll apply the aforementioned changes.
Regarding making it case insensitive, I considered that and did a quick research about it, but all the pieces of information I found said that the performance would be considerably lower than adding both a-z and A-Z. Just let me know if you'd rather taking the chance and making it case insensitive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only used in association with jQuery.parseHTML; any gains would be unnoticeable in the cost of creating elements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. I'll update the code and amend the PR.
|
Friendly ping |
75f679e to
ec5acd9
Compare
|
@gibson042 Please ignore my previous question. I think I got what you meant and updated the PR. |
17ff880 to
de84b98
Compare
test/unit/manipulation.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this! I think my only note is to be more specific about how we're respecting the spec here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My pleasure to help!
Would ...
html(String) respect the spec on how to handle special and name-terminating chars for tag names (gh-2005)
... better describe the changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timmywil Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LeonardoBraga Are you sure? It doesn't look like the change got committed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timmywil My apologies. It's updated now.
828e2ca to
d674651
Compare
|
Just pinging to know if there's anything else I can do to help the team land this PR. Thanks! |
src/manipulation.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this regex need the two negated > in a row? There's one in the modified part and one that was there originally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the two negated >, some tests fail such as this one. It seems that before, the \w was taking care of the job of the first negation, but now we're finding the name-terminating characters explicitly, we'll need to handle this ourselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK that makes sense, thanks!
d674651 to
4abef66
Compare
test/unit/manipulation.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also include / and >.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or rather, those cases should also be tested. It looks like > is covered implicitly, so maybe just add buildChild( method, "<" + nodeName + "/>" ) into the helpers.
|
Sorry for the delay, @LeonardoBraga. Did you check the size impact of moving all the Other than these minor comments, it looks good to me. |
4abef66 to
9ed20d0
Compare
|
@gibson042 Moving Based on my (limited) knowledge about the libraries usage in general, I lean towards benefiting the minified version (by having |
9ed20d0 to
b1f678a
Compare
|
Just touching base to see if there's anything else I can do to help you guys have this PR landed. Thanks! |
|
@LeonardoBraga Sorry for the delay, we're preparing for 1.12/2.2 simultaneous release, your PR is scheduled for 3.0.0 so we'll get to it once we're done with 1.12/2.2. :) |
|
Thanks for your patience, @LeonardoBraga. |
|
Thank you all! I'm just glad I was able to help. :-) |
Closes gh-2005
Implements the recommendations from @gibson042 in this comment.