more aggressively look for disappearing dialogs

This commit is contained in:
Sam Thorogood 2016-11-16 19:37:10 +00:00
Родитель db2c169efd
Коммит a412b0aa90
1 изменённых файлов: 15 добавлений и 16 удалений

Просмотреть файл

@ -354,7 +354,8 @@
this.overlay.className = '_dialog_overlay';
this.overlay.addEventListener('click', function(e) {
e.stopPropagation();
});
this.checkDOM_(); // sanity-check DOM
}.bind(this));
this.handleKey_ = this.handleKey_.bind(this);
this.handleFocus_ = this.handleFocus_.bind(this);
@ -369,7 +370,7 @@
*/
dialogPolyfill.DialogManager.prototype.topDialogElement = function() {
var dpi = this.pendingDialogStack[0];
return dpi ? dpi.dialog_ : null;
return dpi ? dpi.dialog : null;
};
/**
@ -432,23 +433,21 @@
}
};
dialogPolyfill.DialogManager.prototype.handleRemove_ = function(event) {
if (event.target.nodeName.toUpperCase() != 'DIALOG') { return; }
var dialog = /** @type {HTMLDialogElement} */ (event.target);
if (!dialog.open) { return; }
// Find a dialogPolyfillInfo which matches the removed <dialog>.
this.pendingDialogStack.some(function(dpi) {
if (dpi.dialog == dialog) {
// This call will clear the dialogPolyfillInfo on this DialogManager
// as a side effect.
dpi.maybeHideModal();
return true;
}
/**
* Finds and removes any modal dialogs that are no longer on the page.
*/
dialogPolyfill.DialogManager.prototype.checkDOM_ = function() {
var clone = this.pendingDialogStack.slice();
clone.forEach(function(dpi) {
dpi.maybeHideModal();
});
};
dialogPolyfill.DialogManager.prototype.handleRemove_ = function(event) {
if (event.target.nodeName.toUpperCase() !== 'DIALOG') { return; }
this.checkDOM_();
};
/**
* @param {!dialogPolyfillInfo} dpi
* @return {boolean} whether the dialog was allowed