-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
🌸 Cherry pick request for #27783 into #27625/#27765 (Approved) #27790
Labels
Cherry-pick: Beta
Cherry-pick: Experimental
Cherry-pick: Stable
Type: Release
Used to track AMP releases from canary to production
Comments
danielrozenberg
added
Cherry-pick: Beta
Cherry-pick: Experimental
Cherry-pick: LTS
Cherry-pick: Stable
Type: Release
Used to track AMP releases from canary to production
labels
Apr 15, 2020
Approved |
danielrozenberg
changed the title
🌸 Cherry pick request for #27783 into #27625/#27765 (Pending)
🌸 Cherry pick request for #27783 into #27625/#27765 (Approved)
Apr 15, 2020
This was referenced Apr 15, 2020
Post mortem is added. |
@jridgewell You also pointed out was that our error reporter actually caught this. However it was already a hectic release week so it went unnoticed. A more automated alerting mechanism for new errors would help prevent these from slipping under the radar. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Cherry-pick: Beta
Cherry-pick: Experimental
Cherry-pick: Stable
Type: Release
Used to track AMP releases from canary to production
Cherry-pick request
Why does this issue meet the cherry-pick criteria?
Issue #27775 was a serious breaking change that caused us to roll back Stable to a previous version.
Mini-postmortem
Summary
The Custom Elements v1 specification requires that all CEs extend from
HTMLElement
. This is expressed in code asclass MyCustomElement extends HTMLElement {}
. In browsers that don't support CEv1 natively, we provide a polyfill. Part of this polyfill is installing a new constructorHTMLElementPolyfill
that extends from nativeHTMLElement
, then replacingwindow.HTMLElement = HTMLElementPolyfill
.In order to do proper subclassing, the polyfill sets
HTMLElementPolyfill
's prototype chain toHTMLElement
(this is how native subclassing always works). This meansObject.getPrototypeOf(HTMLElementPolyfill) === HTMLElement
andObject.getPrototypeOf(HTMLElementPolyfill.prototype) === HTMLElement.prototype
.In IE11, the
HTMLElement
constructor is a "host object", and not a regular function. Importantly, it does not inherit the usual Function methods.call
,.apply
, etc.When we transpile our class syntax, we emit code like
superClass.call(this)
(this is how you instantiate class instances in ES5), wheresuperClass === HTMLElementPolyfill
. Remember that.call
is usually inherited from Function. But becauseHTMLElementPolyfill
extends fromHTMLElement
, andHTMLElement
doesn't have a.call
, that would cause a "method not defined" error. To fix that, we manually copiedHTMLElementPolyfill.call = Function.call
in #25245.We could always depend on the code transpiling to
superClass.call(this, this)
do to our subclass'sconstructor
super(this)
call. But I eliminated this subclass constructor code in https://github.com/ampproject/amphtml/pull/27470/files#diff-8e1cdba946c07a7e631ef74645a5d6f0L100-L102.When a subclass does not have its own
constructor
, one is provided by default. This default constructor is equivalent tosuper(...arguments)
and transpiles down tosuperClass.apply(this, arguments)
. The is because now the superclass's constructor will receive all arguments, instead of receiving only a single argument as in our old code.Unfortunately,
HTMLElementPolyfill
does not have a.apply
method, just like it didn't have a.call
method. Thus, the new default subclass constructor will throw an error.Impact
<amp-img>
Action Items
master
or were cherry-picked frommaster
/cc @ampproject/wg-approvers @ampproject/cherry-pick-approvers
The text was updated successfully, but these errors were encountered: