Skip to content

Commit

Permalink
Skip unattached shadows (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
weizman authored Oct 28, 2024
1 parent 638676f commit 312f7e2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
16 changes: 13 additions & 3 deletions snow.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ const {
const {
Object,
getFrameElement,
Function
Function,
isConnected
} = __webpack_require__(14);
const {
forEachOpened
Expand All @@ -182,6 +183,9 @@ function findWin(win, frameElement) {
}
for (let i = 0; i < shadows.length; i++) {
const shadow = shadows[i];
if (!isConnected(shadow)) {
continue;
}
const owner = getOwnerWindowOfNode(shadow);
if (owner !== win) {
continue;
Expand Down Expand Up @@ -733,6 +737,7 @@ function setup(win) {
push: Object.getOwnPropertyDescriptor(Array.prototype, 'push').value,
split: Object.getOwnPropertyDescriptor(String.prototype, 'split').value,
nodeType: Object.getOwnPropertyDescriptor(Node.prototype, 'nodeType').get,
isConnected: Object.getOwnPropertyDescriptor(Node.prototype, 'isConnected').get,
tagName: Object.getOwnPropertyDescriptor(Element.prototype, 'tagName').get,
getInnerHTML: Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML').get,
setInnerHTML: Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML').set,
Expand Down Expand Up @@ -777,6 +782,7 @@ function setup(win) {
push,
split,
nodeType,
isConnected,
tagName,
toString,
getOnload,
Expand Down Expand Up @@ -837,6 +843,9 @@ function setup(win) {
function nodeType(node) {
return bag.nodeType.call(node);
}
function isConnected(node) {
return bag.isConnected.call(node);
}
function tagName(element) {
return bag.tagName.call(element);
}
Expand Down Expand Up @@ -1084,12 +1093,13 @@ const {
} = __webpack_require__(648);
const {
Object,
Function
Function,
isConnected
} = __webpack_require__(14);
function protectShadows(connectedOnly) {
for (let i = 0; i < shadows.length; i++) {
const shadow = shadows[i];
if (connectedOnly && !shadow.isConnected) {
if (connectedOnly && !isConnected(shadow)) {
continue;
}
const frames = getFramesArray(shadow, false);
Expand Down
Loading

0 comments on commit 312f7e2

Please sign in to comment.