Skip to content

Commit

Permalink
reject promise when layoutCallback throw
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouyx committed May 17, 2018
1 parent e398a42 commit 3e49c31
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion 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 @@ -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);
Expand Down

0 comments on commit 3e49c31

Please sign in to comment.