Skip to content

Commit 595b239

Browse files
committed
this fixes gorhill#546
1 parent 2560a81 commit 595b239

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/js/scriptlets/dom-inspector.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,15 @@ var cosmeticFilterFromTarget = function(nid, coarseSelector) {
686686
/******************************************************************************/
687687

688688
var cosmeticFilterMapper = (function() {
689+
// https://github.com/gorhill/uBlock/issues/546
690+
var matchesFnName;
691+
if ( typeof document.body.matches === 'function' ) {
692+
matchesFnName = 'matches';
693+
} else if ( typeof document.body.mozMatchesSelector === 'function' ) {
694+
matchesFnName = 'mozMatchesSelector';
695+
} else if ( typeof document.body.webkitMatchesSelector === 'function' ) {
696+
matchesFnName = 'webkitMatchesSelector';
697+
}
689698

690699
// Why the call to hideNode()?
691700
// Not all target nodes have necessarily been force-hidden,
@@ -699,7 +708,7 @@ var cosmeticFilterMapper = (function() {
699708
var selector, nodes, j, node;
700709
while ( i-- ) {
701710
selector = selectors[i];
702-
if ( filterMap.has(rootNode) === false && rootNode.matches(selector) ) {
711+
if ( filterMap.has(rootNode) === false && rootNode[matchesFnName](selector) ) {
703712
filterMap.set(rootNode, selector);
704713
hideNode(node);
705714
}

0 commit comments

Comments
 (0)