Basic info:
- Node.js version: 10.15.2
- jsdom version: 15.1.
Minimal reproduction case
const { JSDOM } = require("jsdom");
const { window: { document } } = new JSDOM(`
<!DOCTYPE html>
<html>
<head>
<title>Parcel Sandbox</title>
<meta charset="UTF-8" />
</head>
<body>
<div id="app"><button>Hello, Dave</button></div>
</body>
</html>
`);
function handleEvent(event) {
console.log(`${event.type} event`, event.target);
}
const button = document.querySelector('button');
button.addEventListener('focus', handleEvent);
button.focus();
button.focus();
https://repl.it/@eps1lonExists/SimpleUnfoldedSequence
How does similar code behave in browsers?
Repeated focus does not fire focus event. It seems like this is matching
If new focus target is the currently focused area of a top-level browsing context, then return.
-- https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps
which isn't implemented by jsdom.
https://codesandbox.io/s/repeated-imperative-focus-2gftr
Misc
Would it be sufficient to check if previous === this and return if this is true after
|
const previous = this._ownerDocument._lastFocusedElement; |
? Couldn't find an existing test in https://github.com/web-platform-tests/wpt/tree/master/html/interaction/focus so I would need to add a new one to the upstream folder too, right?
Basic info:
Minimal reproduction case
https://repl.it/@eps1lonExists/SimpleUnfoldedSequence
How does similar code behave in browsers?
Repeated focus does not fire focus event. It seems like this is matching
-- https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps
which isn't implemented by jsdom.
https://codesandbox.io/s/repeated-imperative-focus-2gftr
Misc
Would it be sufficient to check if
previous === thisand return if this is true afterjsdom/lib/jsdom/living/nodes/HTMLOrSVGElement-impl.js
Line 34 in 529b9f3
? Couldn't find an existing test in https://github.com/web-platform-tests/wpt/tree/master/html/interaction/focus so I would need to add a new one to the upstream folder too, right?