Skip to content

Commit

Permalink
feat: improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Lodin committed Aug 25, 2019
1 parent 5eb3176 commit 70e095a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions adoptedStyleSheets.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,20 @@
resolve(this[$constructStyleSheet].basicStyleElement.sheet);
updateAdopters(this);
} else {
reject('replace can only be called on a constructed style sheet');
reject(
new TypeError(
"Illegal invocation: 'replace' can only be called on a Constructible Style Sheet",
),
);
}
});
}

replaceSync(contents) {
if (importPattern.test(contents)) {
throw new Error(
"@import is not allowed when using CSSStyleSheet's replaceSync method",
throw new DOMException(
'@import rules are not allowed when creating stylesheet synchronously',
'NotAllowedError',
);
}

Expand All @@ -86,7 +91,7 @@
return this[$constructStyleSheet].basicStyleElement.sheet;
} else {
throw new TypeError(
'replaceSync can only be called on a constructed style sheet',
"Illegal invocation: 'replaceSync' can only be called on a Constructible Style Sheet",
);
}
}
Expand Down Expand Up @@ -240,7 +245,7 @@
OldCSSStyleSheet.prototype[methodKey] = function(...args) {
if ($constructStyleSheet in this) {
for (const [, styleElement] of this[$constructStyleSheet].adopters) {
styleElement.sheet[key](...args)
styleElement.sheet[key](...args);
}

// And we also need to remember all these changes to apply them to
Expand Down

0 comments on commit 70e095a

Please sign in to comment.