Skip to content
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

🐛: Reject layoutCallback promise when throw #15410

Merged
merged 3 commits into from
May 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/custom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {isExperimentOn} from './experiments';
import {parseSizeList} from './size-list';
import {setStyle} from './style';
import {toWin} from './types';
import {tryResolve} from '../src/utils/promise';

const TAG = 'CustomElement';

Expand Down Expand Up @@ -111,6 +112,7 @@ export function createCustomElementClass(win, name) {
/**
* @see https://github.com/WebReflection/document-register-element#v1-caveat
* @suppress {checkTypes}
* @param {HTMLElement} self
*/
constructor(self) {
return super(self);
Expand Down Expand Up @@ -139,6 +141,7 @@ function createBaseCustomElementClass(win) {
/**
* @see https://github.com/WebReflection/document-register-element#v1-caveat
* @suppress {checkTypes}
* @param {HTMLElement} self
*/
constructor(self) {
self = super(self);
Expand Down Expand Up @@ -1041,9 +1044,11 @@ function createBaseCustomElementClass(win) {
if (this.perfOn_) {
this.getLayoutDelayMeter_().startLayout();
}
const promise = this.implementation_.layoutCallback();

const promise = tryResolve(() => this.implementation_.layoutCallback());
this.preconnect(/* onLayout */true);
this.classList.add('i-amphtml-layout');

return promise.then(() => {
if (isLoadEvent) {
this.signals_.signal(CommonSignals.LOAD_END);
Expand Down Expand Up @@ -1274,8 +1279,8 @@ function createBaseCustomElementClass(win) {

/**
* Called when one or more attributes are mutated.
* @note Must be called inside a mutate context.
* @note Boolean attributes have a value of `true` and `false` when
* Note Must be called inside a mutate context.
* Note Boolean attributes have a value of `true` and `false` when
* present and missing, respectively.
* @param {
* !JsonObject<string, (null|boolean|string|number|Array|Object)>
Expand Down