Skip to content

[11.2.x] fix(docs-infra): fix angular.io on IE 11#41184

Closed
gkalpak wants to merge 2 commits into
angular:11.2.xfrom
gkalpak:11.2.x-fix-aio-ie
Closed

[11.2.x] fix(docs-infra): fix angular.io on IE 11#41184
gkalpak wants to merge 2 commits into
angular:11.2.xfrom
gkalpak:11.2.x-fix-aio-ie

Conversation

@gkalpak

@gkalpak gkalpak commented Mar 11, 2021

Copy link
Copy Markdown
Member

This is a backport of #41162 to the 11.2.x branch.

  • fix(docs-infra): avoid unnecessarily loading Custom Elements ES5 shim:
    The custom elements spec is not compatible with ES5 style classes. This means ES2015 code compiled to ES5 will not work with a native implementation of Custom Elements. To support browsers that natively support Custom Elements but not ES2015 modules, we load @webcomponents/custom-elements/src/native-shim.js, which minimally augments the native implementation to be compatible with ES5 code.
    (See here for more details.)

    Previously, the shim was included in polyfills.ts, which meant it was loaded in all browsers (even those supporting ES2015 modules and thus not needing the shim).

    This commit moves the shim from polyfills.ts to a nomodule script tag in index.html. This will ensure that it is only loaded in browsers that do not support ES2015 modules and thus do not needed the shim.

    NOTE:
    This commit also reduces size of the polyfills bundle by ~400B (52609B --> 52215B).

  • fix(docs-infra): fix angular.io on IE 11:
    Previously, the angular.io app was broken on IE 11. In particular, pages that included Custom Elements would fail to load, because the Reflect.construct() method (which the Custom Elements ES5 shim relies on) was not available.

    This commit fixes this by loading the polyfill for Reflect.construct() on browsers that do not support ES2015 (including IE 11).

gkalpak added 2 commits March 11, 2021 19:52
…angular#41162)

The custom elements spec is not compatible with ES5 style classes. This
means ES2015 code compiled to ES5 will not work with a native
implementation of Custom Elements. To support browsers that natively
support Custom Elements but not ES2015 modules, we load
`@webcomponents/custom-elements/src/native-shim.js`, which minimally
augments the native implementation to be compatible with ES5 code.
(See [here][1] for more details.)

Previously, the shim was included in `polyfills.ts`, which meant it was
loaded in all browsers (even those supporting ES2015 modules and thus
not needing the shim).

This commit moves the shim from `polyfills.ts` to a `nomodule` script
tag in `index.html`. This will ensure that it is only loaded in browsers
that do not support ES2015 modules and thus do not needed the shim.

NOTE:
This commit also reduces size of the polyfills bundle by ~400B
(52609B --> 52215B).

[1]: https://www.npmjs.com/package/@webcomponents/custom-elements#es5-vs-es2015

PR Close angular#41162
Previously, the angular.io app was broken on IE 11. In particular, pages
that included Custom Elements would fail to load, because the
`Reflect.construct()` method (which the Custom Elements ES5 shim relies
on) was not available.

This commit fixes this by loading the polyfill for `Reflect.construct()`
on browsers that do not support ES2015 (including IE 11).

PR Close angular#41162
@gkalpak gkalpak added this to the docs-infra-aio-app milestone Mar 11, 2021
@google-cla google-cla Bot added the cla: yes label Mar 11, 2021
@mary-poppins

Copy link
Copy Markdown

You can preview 51ecd79 at https://pr41184-51ecd79.ngbuilds.io/.

@gkalpak gkalpak marked this pull request as ready for review March 11, 2021 18:54
@AndrewKushnir AndrewKushnir added the action: merge The PR is ready for merge by the caretaker label Mar 11, 2021
@AndrewKushnir

Copy link
Copy Markdown
Contributor

Closed by commit 74aba13

AndrewKushnir pushed a commit that referenced this pull request Mar 11, 2021
…#41162) (#41184)

The custom elements spec is not compatible with ES5 style classes. This
means ES2015 code compiled to ES5 will not work with a native
implementation of Custom Elements. To support browsers that natively
support Custom Elements but not ES2015 modules, we load
`@webcomponents/custom-elements/src/native-shim.js`, which minimally
augments the native implementation to be compatible with ES5 code.
(See [here][1] for more details.)

Previously, the shim was included in `polyfills.ts`, which meant it was
loaded in all browsers (even those supporting ES2015 modules and thus
not needing the shim).

This commit moves the shim from `polyfills.ts` to a `nomodule` script
tag in `index.html`. This will ensure that it is only loaded in browsers
that do not support ES2015 modules and thus do not needed the shim.

NOTE:
This commit also reduces size of the polyfills bundle by ~400B
(52609B --> 52215B).

[1]: https://www.npmjs.com/package/@webcomponents/custom-elements#es5-vs-es2015

PR Close #41162

PR Close #41184
AndrewKushnir pushed a commit that referenced this pull request Mar 11, 2021
Previously, the angular.io app was broken on IE 11. In particular, pages
that included Custom Elements would fail to load, because the
`Reflect.construct()` method (which the Custom Elements ES5 shim relies
on) was not available.

This commit fixes this by loading the polyfill for `Reflect.construct()`
on browsers that do not support ES2015 (including IE 11).

PR Close #41162

PR Close #41184
@gkalpak gkalpak deleted the 11.2.x-fix-aio-ie branch March 12, 2021 12:45
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Apr 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes PullApprove: disable target: patch This PR is targeted for the next patch release type: bug/fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants