From f773299e9f9107ae80df933a6cea8e050563fb9b Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Wed, 29 Jun 2016 13:10:53 -0400 Subject: [PATCH] Convert custom element callbacks to Web IDL callback types This ensures that the incumbent global is correctly set up when calling them. We also remove the redundant "prepare to run script" and "clean up after running script" in the element definition algorithm, since element definition happens synchronously from user code. Part of #855. --- source | 53 +++++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/source b/source index 7c905d3f93f..e3d5ae8b3f9 100644 --- a/source +++ b/source @@ -2917,8 +2917,8 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
  • ArrayBufferView
  • boolean
  • DOMString -
  • USVString
  • double +
  • enumeration
  • Error
  • Function
  • long @@ -2927,7 +2927,7 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
  • Uint8ClampedArray
  • unrestricted double
  • unsigned long -
  • enumeration +
  • USVString @@ -66330,8 +66330,9 @@ console.log(plasticButton2.getAttribute("is")); // will output "plastic-button"< data-x="concept-custom-element-definition-lifecycle-callbacks">lifecycle callbacks
    A map, whose three keys are the strings "connectedCallback", "disconnectedCallback", and "attributeChangedCallback". The corresponding values are either a JavaScript - function object, or undefined. By default the value of each entry is undefined.
    + data-x="">attributeChangedCallback". The corresponding values are either a Web IDL + Function callback function type value, or null. By default the + value of each entry is null.
    A construction stack
    @@ -66534,8 +66535,6 @@ dictionary ElementDefinitionOptions {
  • Add constructor to this CustomElementsRegistry's set of being-defined constructors.

  • -
  • Prepare to run script with the current settings object.

  • -
  • Run the following substeps while catching any exceptions:

    @@ -66546,35 +66545,44 @@ dictionary ElementDefinitionOptions {
  • If Type(prototype) is not Object, then throw a TypeError exception.

  • -
  • Let connectedCallback be Get(prototype, - "connectedCallback"). Rethrow any exceptions.

  • +
  • Let connectedCallback, disconnectedCallback, and + attributeChangedCallback be null.

    -
  • If connectedCallback is not undefined, and - IsCallable(connectedCallback) is false, then throw a - TypeError exception.

  • +
  • Let connectedCallbackValue be Get(prototype, "connectedCallback"). Rethrow any + exceptions.

  • -
  • Let disconnectedCallback be

    If connectedCallbackValue is not undefined, then set + connectedCallback to the result of converting connectedCallbackValue to the Web IDL + Function callback type. Rethrow any exceptions.

  • + +
  • Let disconnectedCallbackValue be Get(prototype, "disconnectedCallback"). Rethrow any exceptions.

  • -
  • If disconnectedCallback is not undefined, and - IsCallable(disconnectedCallback) is false, then throw a - TypeError exception.

  • +
  • If disconnectedCallbackValue is not undefined, then set + disconnectedCallback to the result of converting disconnectedCallbackValue to the Web + IDL Function callback type. Rethrow any exceptions.

  • -
  • Let attributeChangedCallback be

    Let attributeChangedCallbackValue be Get(prototype, "attributeChangedCallback"). Rethrow any exceptions.

  • +
  • If attributeChangedCallbackValue is not undefined, then set + attributeChangedCallback to the result of converting attributeChangedCallbackValue to the + Web IDL Function callback type. Rethrow any + exceptions.

  • +
  • Let observedAttributes be an empty sequence<DOMString>.

  • -

    If attributeChangedCallback is not undefined, then:

    +

    If attributeChangedCallback is not null, then:

      -
    1. If IsCallable(attributeChangedCallback) is false, then throw - a TypeError exception.

    2. -
    3. Let observedAttributesIterable be Get(constructor, "observedAttributes"). Rethrow any exceptions.

    4. @@ -66590,9 +66598,6 @@ dictionary ElementDefinitionOptions { exception or not:

        -
      1. Clean up after running script with the current settings - object.

      2. -
      3. Remove name from this CustomElementsRegistry's set of being-defined names.

      4. @@ -66964,7 +66969,7 @@ customElements.define("x-foo", class extends HTMLElement { data-x="concept-custom-element-definition-lifecycle-callbacks">lifecycle callbacks with key callbackName.

        -
      5. If callback is undefined, then abort these steps.

      6. +
      7. If callback is null, then abort these steps.

      8. If callbackName is "attributeChangedCallback", then: