From 1cf77ea6b15842a6a6793ca04c49aefd520f0f51 Mon Sep 17 00:00:00 2001 From: zhouyx Date: Thu, 17 May 2018 14:36:00 -0700 Subject: [PATCH 1/3] reject promise when layoutCallback throw --- src/custom-element.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/custom-element.js b/src/custom-element.js index 43488bd6d76b..8e6aa7c77b48 100644 --- a/src/custom-element.js +++ b/src/custom-element.js @@ -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'; @@ -1041,9 +1042,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); From a98c0563cb026f1fa465868ed36955746e4119fa Mon Sep 17 00:00:00 2001 From: zhouyx Date: Thu, 17 May 2018 15:35:28 -0700 Subject: [PATCH 2/3] fix lint --- src/custom-element.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/custom-element.js b/src/custom-element.js index 8e6aa7c77b48..b9b638416fa5 100644 --- a/src/custom-element.js +++ b/src/custom-element.js @@ -45,7 +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'; +import {tryResolve} from '../src/utils/promise'; const TAG = 'CustomElement'; @@ -112,6 +112,7 @@ export function createCustomElementClass(win, name) { /** * @see https://github.com/WebReflection/document-register-element#v1-caveat * @suppress {checkTypes} + * @param {CustomAmpElement} self */ constructor(self) { return super(self); @@ -140,6 +141,7 @@ function createBaseCustomElementClass(win) { /** * @see https://github.com/WebReflection/document-register-element#v1-caveat * @suppress {checkTypes} + * @param {BaseCustomElement} self */ constructor(self) { self = super(self); @@ -1277,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 From 460b3e475daedfd3629f98e109149e2380261898 Mon Sep 17 00:00:00 2001 From: zhouyx Date: Thu, 17 May 2018 16:23:19 -0700 Subject: [PATCH 3/3] check-type fix --- src/custom-element.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/custom-element.js b/src/custom-element.js index b9b638416fa5..bea9d68ab2ff 100644 --- a/src/custom-element.js +++ b/src/custom-element.js @@ -112,7 +112,7 @@ export function createCustomElementClass(win, name) { /** * @see https://github.com/WebReflection/document-register-element#v1-caveat * @suppress {checkTypes} - * @param {CustomAmpElement} self + * @param {HTMLElement} self */ constructor(self) { return super(self); @@ -141,7 +141,7 @@ function createBaseCustomElementClass(win) { /** * @see https://github.com/WebReflection/document-register-element#v1-caveat * @suppress {checkTypes} - * @param {BaseCustomElement} self + * @param {HTMLElement} self */ constructor(self) { self = super(self);