allow form inside dialog without specified method
This commit is contained in:
Родитель
8a5f2b0590
Коммит
466ee78ee8
|
@ -458,8 +458,9 @@
|
|||
* and possibly sets its return value.
|
||||
*/
|
||||
document.addEventListener('submit', function(ev) {
|
||||
var method = ev.target.getAttribute('method').toLowerCase();
|
||||
if (method != 'dialog') { return; }
|
||||
var target = ev.target;
|
||||
if (!target || !target.hasAttribute('method')) { return; }
|
||||
if (target.getAttribute('method').toLowerCase() != 'dialog') { return; }
|
||||
ev.preventDefault();
|
||||
|
||||
var dialog = findNearestDialog(/** @type {Element} */ (ev.target));
|
||||
|
|
18
suite.js
18
suite.js
|
@ -481,6 +481,24 @@ void function() {
|
|||
assert.equal(dialog.returnValue, button.value,
|
||||
'don\'t take button textContent as value');
|
||||
});
|
||||
test('boring form inside dialog', function() {
|
||||
var form = document.createElement('form');
|
||||
dialog.appendChild(form); // don't specify method
|
||||
form.addEventListener('submit', function(ev) {
|
||||
ev.preventDefault();
|
||||
});
|
||||
|
||||
var button = document.createElement('button');
|
||||
button.value = 'Moot';
|
||||
form.appendChild(button);
|
||||
|
||||
dialog.showModal();
|
||||
button.focus(); // emulate user focus action
|
||||
button.click();
|
||||
|
||||
assert.isTrue(dialog.open, 'non-dialog form should not close dialog')
|
||||
assert(!dialog.returnValue);
|
||||
});
|
||||
});
|
||||
|
||||
suite('order', function() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче