Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Manipulation: Don't remove HTML comments from scripts#4905

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mgol merged 2 commits intojquery:3.x-stablefrommgol:3.x-html-comments-scripts
Jul 19, 2021

Conversation

mgol
Copy link
Member

@mgolmgol commentedJul 15, 2021
edited
Loading

Summary

When evaluating scripts, jQuery strips out the possible wrapping HTML comment
and a CDATA section. However, all supported browsers are already doing that
when loading JS via appending a script tag to the DOM which is how we've been
doingjQuery.globalEval since jQuery 3.0.0. jQuery logic was imperfect, e.g.
it just stripped the<!-- and--> markers, respectively at the beginning or
the end of the script contents. However, browsers are also stripping everything
following those markers in the same line, treating them as single-line comments
delimiters; this is now also mandated by ECMAScript 2015 in Annex B. Instead
of fixing the jQuery logic, just let the browser do its thing.

We still need to strip CDATA sections for backwards compatibility. This
shouldn't be needed as in XML documents they're already not visible when
inspecting element contents and in HTML documents they have no meaning but
we're preserving that logic for backwards compatibility. This will be removed
completely in 4.0.

Fixesgh-4904

-8 bytes

4.0 version of this PR:#4906

Checklist

When evaluating scripts, jQuery strips out the possible wrapping HTML commentand a CDATA section. However, all supported browsers are already doing thatwhen loading JS via appending a script tag to the DOM which is how we've beendoing `jQuery.globalEval` since jQuery 3.0.0. jQuery logic was imperfect, e.g.it just stripped the `<!--` and `-->` markers, respectively at the beginning orthe end of the script contents. However, browsers are also stripping everythingfollowing those markers in the same line, treating them as single-line commentsdelimiters; this is now also mandated by ECMAScript 2015 in Annex B. Insteadof fixing the jQuery logic, just let the browser do its thing.We still need to strip CDATA sections for backwards compatibility. Thisshouldn't be needed as in XML documents they're already not visible wheninspecting element contents and in HTML documents they have no meaning butwe're preserving that logic for backwards compatibility. This will be removedcompletely in 4.0.Fixesjquerygh-4904
@mgolmgol added this to the3.6.1 milestoneJul 15, 2021
@mgolmgol self-assigned thisJul 15, 2021
@mgolmgol changed the titleManipulation: Don't remove HTML comments from scriptsManipulation: Don't remove HTML comments from scripts (3.x version)Jul 15, 2021
Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
@mgolmgol changed the titleManipulation: Don't remove HTML comments from scripts (3.x version)Manipulation: Don't remove HTML comments from scriptsJul 19, 2021
@mgolmgol merged commit924b515 intojquery:3.x-stableJul 19, 2021
@mgolmgol deleted the 3.x-html-comments-scripts branchJuly 19, 2021 17:15
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@gibson042gibson042gibson042 approved these changes

@timmywiltimmywiltimmywil approved these changes

Assignees

@mgolmgol

Milestone
3.6.1
Development

Successfully merging this pull request may close these issues.

3 participants
@mgol@timmywil@gibson042

[8]ページ先頭

©2009-2025 Movatter.jp