From ef23886d5aa93b04f560ea3b7c942d07713c58e3 Mon Sep 17 00:00:00 2001 From: Stefan Zager Date: Wed, 17 Feb 2016 15:35:50 -0800 Subject: [PATCH] Specify lifetime for observers. --- index.bs | 34 +++++++++++++++++++++++++++------- index.html | 31 +++++++++++++++++++++++-------- 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/index.bs b/index.bs index 8693884..53ab791 100644 --- a/index.bs +++ b/index.bs @@ -36,9 +36,10 @@ urlPrefix: https://heycam.github.io/webidl/ text: RangeError text: TypeError text: SyntaxError - url: #dom-domexception-hierarchy_request_err; type: exception; text: HierarchyRequestError urlPrefix: #dfn-; type:dfn; text: throw urlPrefix: #idl-; type:interface; text: double + url: #hierarchyrequesterror; type: exception; text: HierarchyRequestError + url: #invalidstateerror; type: exception; text: InvalidStateError url: https://drafts.csswg.org/css2/box.html#content-edge; type:dfn; text: content-box urlPrefix: https://drafts.csswg.org/css-box/ url: #viewport; type: dfn; text: viewport @@ -223,16 +224,14 @@ interface IntersectionObserver { :: 1. If |target| is in |this|'s internal {{[[ObservationTargets]]}} slot, return. - 2. If |target| is NOT a descendent of |this|.|root|, - throw a {{HierarchyRequestError}}. - 3. Let |intersectionObserverRegistration| be + 2. Let |intersectionObserverRegistration| be an {{IntersectionObserverRegistration}} record with an {{IntersectionObserverRegistration/observer}} property set to |this| and a {{IntersectionObserverRegistration/previousThreshold}} property set to 0. - 4. Append |intersectionObserverRegistration| + 3. Append |intersectionObserverRegistration| to |target|'s internal {{[[RegisteredIntersectionObservers]]}} slot. - 5. Add |target| to |this|'s internal {{[[ObservationTargets]]}} slot. - 6. Schedule an iteration of the event loop + 4. Add |target| to |this|'s internal {{[[ObservationTargets]]}} slot. + 5. Schedule an iteration of the event loop in the {{IntersectionObserver/root}}'s browsing context. : unobserve(target) :: @@ -625,6 +624,27 @@ To run the update intersection observations steps for an 12. Assign |threshold| to |intersectionObserverRegistration|'s {{IntersectionObserverRegistration/previousThreshold}} property. +

+IntersectionObserver Lifetime

+ +An {{IntersectionObserver}} will remain alive until both of these conditions hold: + + +An {{IntersectionObserver}} will continue observing a target until any of the following occurs: + + +If an {{IntersectionObserver}}'s intersection root is deleted +while there are still JavaScript references to the observer, +calling any API method on the observer will throw an {{InvalidStateError}}. +

External Spec Integrations

diff --git a/index.html b/index.html index 1841625..a9d0b4c 100644 --- a/index.html +++ b/index.html @@ -1354,7 +1354,7 @@

Intersection Observer

-

Editor’s Draft,

+

Editor’s Draft,

This version: @@ -1368,7 +1368,7 @@

@@ -1410,10 +1410,11 @@

Table of Contents

  • 3.2.4 Compute the Intersection of a Target Element and the Root
  • 3.2.5 Run the Update Intersection Observations Steps +
  • 3.3 IntersectionObserver Lifetime
  • - 3.3 External Spec Integrations + 3.4 External Spec Integrations
      -
    1. 3.3.1 HTML Processing Model: Event Loop +
    2. 3.4.1 HTML Processing Model: Event Loop
  • Conformance @@ -1580,8 +1581,6 @@

    If target is in this’s internal [[ObservationTargets]] slot, return.

    -
  • -

    If target is NOT a descendent of this.root, throw a HierarchyRequestError.

  • Let intersectionObserverRegistration be an IntersectionObserverRegistration record @@ -1969,8 +1968,24 @@

    3.3. External Spec Integrations

    -

    3.3.1. HTML Processing Model: Event Loop

    +

    3.3. IntersectionObserver Lifetime

    +

    An IntersectionObserver will remain alive until both of these conditions hold:

    +
      +
    • There are no scripting references to the observer. +
    • The observer is not observing any targets. +
    +

    An IntersectionObserver will continue observing a target until any of the following occurs:

    + +

    If an IntersectionObserver's intersection root is deleted +while there are still JavaScript references to the observer, +calling any API method on the observer will throw an InvalidStateError.

    +

    3.4. External Spec Integrations

    +

    3.4.1. HTML Processing Model: Event Loop

    An Intersection Observer processing step should take place at the end of the "Update the rendering" steps in the event loop