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#4906

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 1 commit intojquery:mainfrommgol: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 also used to strip CDATA sections. However, 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. We've preserved that behavior for
backwards compatibility in 3.x but we're removing it for 4.0.

Fixesgh-4904

-44 bytes

3.x version of this PR:#4905

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 also used to strip CDATA sections. However, this shouldn't be needed as inXML documents they're already not visible when inspecting element contents andin HTML documents they have no meaning. We've preserved that behavior forbackwards compatibility in 3.x but we're removing it for 4.0.Fixesjquerygh-4904
Copy link
Member

@timmywiltimmywil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Makes sense. LGTM

@mgolmgol merged commit2f8f39e intojquery:mainJul 19, 2021
@mgolmgol deleted the html-comments-scripts branchJuly 19, 2021 17:04
mgol added a commit that referenced this pull requestJul 19, 2021
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.Fixesgh-4904Closesgh-4905Refgh-4906
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@timmywiltimmywiltimmywil approved these changes

@gibson042gibson042gibson042 approved these changes

Assignees

@mgolmgol

Milestone
4.0.0
Development

Successfully merging this pull request may close these issues.

HTML style comment breaks script
3 participants
@mgol@timmywil@gibson042

[8]ページ先頭

©2009-2025 Movatter.jp