Skip to content

Commit

Permalink
fix #3321: make uBO the bigger person and walk away from a pointless …
Browse files Browse the repository at this point in the history
…fight
  • Loading branch information
gorhill committed Dec 5, 2017
1 parent e7d5c83 commit 88ce175
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions platform/chromium/vapi-usercss.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ if ( typeof vAPI === 'object' ) { // >>>>>>>> start of HUGE-IF-BLOCK

vAPI.userStylesheet = {
style: null,
styleFixCount: 0,
css: new Map(),
disabled: false,
apply: function() {
Expand All @@ -47,7 +48,12 @@ vAPI.userStylesheet = {
var observer = new MutationObserver(function() {
if ( this.style === null ) { return; }
if ( this.style.sheet !== null ) { return; }
parent.appendChild(this.style);
this.styleFixCount += 1;
if ( this.styleFixCount < 32 ) {
parent.appendChild(this.style);
} else {
observer.disconnect();
}
}.bind(this));
observer.observe(parent, { childList: true });
},
Expand All @@ -66,11 +72,13 @@ vAPI.userStylesheet = {
if ( cssRule === undefined ) { return; }
this.css.delete(cssText);
if ( this.style === null ) { return; }
var rules = this.style.sheet.cssRules,
var sheet = this.style.sheet;
if ( !sheet ) { return; }
var rules = sheet.cssRules,
i = rules.length;
while ( i-- ) {
if ( rules[i] !== cssRule ) { continue; }
this.style.sheet.deleteRule(i);
sheet.deleteRule(i);
break;
}
if ( rules.length !== 0 ) { return; }
Expand Down

0 comments on commit 88ce175

Please sign in to comment.