Skip to content

Commit

Permalink
Merge pull request #862 from erwinmombay/fix-race-pt2
Browse files Browse the repository at this point in the history
fix: make sure to do the dom mutation inside a `deferMutate`
  • Loading branch information
erwinmombay committed Nov 4, 2015
2 parents 8b21956 + 75eb290 commit 36cc8af
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions builtins/amp-ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export function installAd(win) {

// Triggered by context.noContentAvailable() inside the ad iframe.
const unlisten = listen(this.iframe_, 'no-content', () => {
this.noContentHandler_();
this.deferMutate(this.noContentHandler_.bind(this));
unlisten();
});
}
Expand All @@ -257,7 +257,6 @@ export function installAd(win) {
this.setDefaultFallback_();
this.element.appendChild(this.fallback_);
}

this.element.removeChild(this.iframe_);
this.toggleFallback(true);
}
Expand Down
3 changes: 2 additions & 1 deletion src/base-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ export class BaseElement {
}

/**
* Hides or shows the fallback, if available.
* Hides or shows the fallback, if available. This function must only
* be called inside a mutate context.
* @param {boolean} state
* @protected @final
*/
Expand Down
3 changes: 2 additions & 1 deletion src/custom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,8 @@ export function createAmpElementProto(win, name, implementationClass) {
};

/**
* Hides or shows the fallback, if available.
* Hides or shows the fallback, if available. This function must only
* be called inside a mutate context.
* @param {boolean} state
* @package @final
*/
Expand Down

0 comments on commit 36cc8af

Please sign in to comment.