зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1333711 - guard against DOMExceptions when accessing stylesheet cssRules;r=gl
MozReview-Commit-ID: C2OoN0uZIo --HG-- extra : rebase_source : 0e72e7c14242a020e3fe392b43e96ff12f9a613e
This commit is contained in:
Родитель
f203d9afbf
Коммит
bb6d3532c3
|
@ -249,7 +249,7 @@ CssLogic.prototype = {
|
|||
cssSheet._passId = this._passId;
|
||||
|
||||
// Find import and keyframes rules.
|
||||
for (let aDomRule of domSheet.cssRules) {
|
||||
for (let aDomRule of cssSheet.getCssRules()) {
|
||||
if (aDomRule.type == CSSRule.IMPORT_RULE &&
|
||||
aDomRule.styleSheet &&
|
||||
this.mediaMatches(aDomRule)) {
|
||||
|
@ -819,9 +819,29 @@ CssSheet.prototype = {
|
|||
* @return {number} the number of nsIDOMCSSRule objects in this stylesheet.
|
||||
*/
|
||||
get ruleCount() {
|
||||
return this._ruleCount > -1 ?
|
||||
this._ruleCount :
|
||||
this.domSheet.cssRules.length;
|
||||
try {
|
||||
return this._ruleCount > -1 ?
|
||||
this._ruleCount :
|
||||
this.getCssRules().length;
|
||||
} catch (e) {
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieve the array of css rules for this stylesheet.
|
||||
*
|
||||
* Accessing cssRules on a stylesheet that is not completely loaded can throw a
|
||||
* DOMException (Bug 625013). This wrapper will return an empty array instead.
|
||||
*
|
||||
* @return {Array} array of css rules.
|
||||
**/
|
||||
getCssRules: function () {
|
||||
try {
|
||||
return this.domSheet.cssRules;
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче