Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 0d7acda

Browse files
author
Arthur Evans
committed
Corrected usage of afterNextRender.
1 parent 406873f commit 0d7acda

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

app/2.0/docs/upgrade.md

+20-10
Original file line numberDiff line numberDiff line change
@@ -661,22 +661,28 @@ After {.caption}
661661

662662
```
663663
attached: function() {
664-
Polymer.RenderStatus.afterNextRender(function() {
664+
// 1st argument to afterNextRender is used as the "this"
665+
// value when the callback is invoked.
666+
Polymer.RenderStatus.afterNextRender(this, function() {
665667
// measure something
666-
}.bind(this))
668+
});
667669
}
668670
```
669671

670-
Deferring work until after the constructor completes using `setTimeout` or `requestAnimationFrame`.
671-
672672

673673
#### Ready time {#ready-time}
674674

675-
The `ready` callback, for one-time initialization, signals the creation of the element's shadow DOM. In the case of class-based elements, you need to call `super.ready()` before accessing the shadow tree.
675+
The `ready` callback, for one-time initialization, signals the creation of the element's shadow DOM.
676+
In the case of class-based elements, you need to call `super.ready()` before accessing the shadow
677+
tree.
676678

677-
The major difference between 1.x and 2.0 has to do with the timing of initial light DOM distribution. In the v1 shady DOM polyfill, initial distribution of children into `<slot>` is asynchronous (microtask) to creating the `shadowRoot`, meaning distribution occurs after observers are run and `ready` is called. In the Polymer 1.0 shim, initial distribution occurred before `ready`.
679+
The major difference between 1.x and 2.0 has to do with the timing of initial light DOM distribution.
680+
In the v1 shady DOM polyfill, initial distribution of children into `<slot>` is asynchronous
681+
(microtask) to creating the `shadowRoot`, meaning distribution occurs after observers are run and
682+
`ready` is called. In the Polymer 1.0 shim, initial distribution occurred before `ready`.
678683

679-
To check the initial distribution, use `setTimeout` or `requestAnimationFrame` from `ready`. The callback should fire after initial distribution is complete.
684+
To check the initial distribution, use `setTimeout` or `requestAnimationFrame` from `ready`. The
685+
callback should fire after initial distribution is complete.
680686

681687

682688
```
@@ -688,7 +694,8 @@ ready: function() {
688694
```
689695

690696

691-
You can use a `slotchange` event listener to react to runtime changes to distribution, but the event listener doesn't fire for the *initial* distribution.
697+
You can use a `slotchange` event listener to react to runtime changes to distribution, but the event
698+
listener doesn't fire for the *initial* distribution.
692699

693700

694701
```
@@ -700,11 +707,14 @@ ready: function() {
700707
```
701708

702709

703-
In order to force distribution synchronously, call `ShadyDOM.flush()`. This can be useful for unit tests.
710+
In order to force distribution synchronously, call `ShadyDOM.flush()`. This can be useful for unit
711+
tests.
712+
704713

705714
### Remove type-extension elements {#remove-type-extension-elements}
706715

707-
Polymer doesn't support type-extension elements (such as `<input is="iron-input">`). For a discussion of this change, see [Type-extension elements](about_20#type-extension)
716+
Polymer doesn't support type-extension elements (such as `<input is="iron-input">`). For a discussion
717+
of this change, see [Type-extension elements](about_20#type-extension)
708718

709719

710720

0 commit comments

Comments
 (0)