Skip to content

Commit a3f3fc7

Browse files
authored
postcss-focus-within : browser compat (#520)
* postcss-focus-within : browser compat * lint
1 parent 30f114f commit a3f3fc7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

plugins/postcss-focus-within/src/browser.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ export default function focusWithin(opts) {
6565
const handleFocusChange = generateHandler(options.replaceWith);
6666

6767
const initialize = function initializeEventListeners() {
68-
document.documentElement.classList.add('js-focus-within');
68+
if (document.documentElement.className.indexOf('js-focus-within') > -1) {
69+
return;
70+
}
71+
72+
document.documentElement.className = document.documentElement.className + ' js-focus-within';
6973
document.addEventListener('focus', handleFocusChange, true);
7074
document.addEventListener('blur', handleFocusChange, true);
7175
};

plugins/postcss-focus-within/test/_browser.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<link rel="stylesheet" href="/test/browser.expect.css">
88
<script src="/dist/browser-global.js"></script>
99
<script>self._focusWithinInit = focusWithinInit</script>
10+
<script>self._focusWithinInit()</script>
1011
</head>
1112
<body>
1213
<div id="a-grand-parent">

0 commit comments

Comments
 (0)