-
Notifications
You must be signed in to change notification settings - Fork 470
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
Update list of self-closing tags #444
Comments
Thanks for the report. The regex is what's included in jQuery 3.4.1, see https://github.com/jquery/jquery/blob/3.4.1/src/manipulation.js#L39. The purpose is to mimic that version behavior so that any HTML string that would be replaced by That said, for void elements like There's always some risk of apps breaking because this replacement was doing an incorrect thing the app now depends on and if we stop replacing the tag, it will break. I suspect the risk is very low here, though. @jquery/core what do you think? The problem is if code tries to be both HTML & XHTML-compliant then they have to use self-closing tags for void elements which triggers Migrate warnings if we don't add them all to the list. @christianwach would you be interested in a PR for the regex? |
@mgol Thanks for your response. I wanted to open an issue first to see if there were reasons for the current list. I'm happy to open a PR, but it looks like it'd be a good idea to keep this repo in sync with jQuery too. I'll pause for the time being to see how others respond. |
Keeping it in sync with jQuery means not changing it since that regex was removed from jQuery 3.5.0; that's the reason why it's in Migrate. I think updating it should be fine but yeah, let's wait for what others thing before spending time on a fix. |
Ha, good point! 🤦 |
@christianwach Looking at it again, the logic in Migrate is not just comparing input with output but it's also seeing if the resulting HTML has any differences. Therefore, if those self-closing tags behave in the same way whether the input is replaced by jQuery or not, there would be no warning. Since you've said you're seeing warnings, this suggests you have a real issue to fix. Can you modify your Migrate copy locally so that just before the line where warnings are set you're also logging the output of |
@mgol Sure thing. Consider this snippet: <video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4" />
<source src="movie.ogg" type="video/ogg" />
Your browser does not support the video tag.
</video> The current implementation transforms this to: <video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4"></source>
<source src="movie.ogg" type="video/ogg"></source>
Your browser does not support the video tag.
</video> Since |
Thanks, but it's not exactly what I asked about. It's not about the HTML string before & after jQuery transforms it as this in itself is not enough to trigger the warning. Migrate, when the before & after strings differ, constructs inert DOM subtrees setting Can you share the outputs of relevant |
@christianwach hey, could you answer my last question? |
@mgol Ah sorry, been snowed under with work lately. You seem to be right about the transforms... my mistake. I thought the So, given that the markup is a full page generated by WordPress, it seems likely that other factors are at play here too. I can point you to examples of the issue in the wild but perhaps it's a bit of a whack-a-mole situation given the variability of the context. I'll close this issue for now since I'm happy to work with a modified copy of jQuery Migrate for development purposes - and other can find it if they want to revive it. Thanks for your feedback and attention Michał. |
I keep getting
HTML tags must be properly nested and closed
warnings because the<source>
tag is not declared in therxhtmlTag
pattern. Seems as though it could be usefully updated to include a fuller set of self-closing tags, e.g.Thanks!
The text was updated successfully, but these errors were encountered: