Skip to content

Commit

Permalink
Skip unnecessary access to cssText property
Browse files Browse the repository at this point in the history
  • Loading branch information
autologie authored Dec 28, 2023
1 parent 792877d commit 180cab1
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/CSSStyleDeclaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ var CSSStyleDeclaration = function CSSStyleDeclaration(onChangeCallback) {
this._values = {};
this._importants = {};
this._length = 0;
this._onChange =
onChangeCallback ||
function () {
return;
};
this._onChange = onChangeCallback;
};
CSSStyleDeclaration.prototype = {
constructor: CSSStyleDeclaration,
Expand Down Expand Up @@ -91,7 +87,9 @@ CSSStyleDeclaration.prototype = {
}
this._values[name] = value;
this._importants[name] = priority;
this._onChange(this.cssText);
if (this._onChange) {
this._onChange(this.cssText);
}
},

/**
Expand Down Expand Up @@ -121,7 +119,9 @@ CSSStyleDeclaration.prototype = {
// That's what Firefox does
//this[index] = ""

this._onChange(this.cssText);
if (this._onChange) {
this._onChange(this.cssText);
}
return prevValue;
},

Expand Down Expand Up @@ -206,7 +206,9 @@ Object.defineProperties(CSSStyleDeclaration.prototype, {
dummyRule.getPropertyPriority(name)
);
}
this._onChange(this.cssText);
if (this._onChange) {
this._onChange(this.cssText);
}
},
enumerable: true,
configurable: true,
Expand Down

0 comments on commit 180cab1

Please sign in to comment.