Skip to content

Commit

Permalink
refactor: remove Terser annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Lodin committed May 14, 2021
1 parent 1681d7b commit 1ae8460
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
5 changes: 1 addition & 4 deletions src/ConstructedStyleSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ export function restyleAdopter(
): void {
requestAnimationFrame(() => {
clearRules(adopter.sheet!);
/*#__INLINE__*/ insertAllRules(
$basicStyleSheet.get(sheet)!,
adopter.sheet!,
);
insertAllRules($basicStyleSheet.get(sheet)!, adopter.sheet!);
});
}

Expand Down
5 changes: 2 additions & 3 deletions src/Location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,15 @@ proto.update = function update(sheets: readonly ConstructedStyleSheet[]) {

self.sheets = sheets;
const oldUniqueSheets = $uniqueSheets.get(self)!;
const uniqueSheets = /*#__INLINE__*/ unique(sheets);
const uniqueSheets = unique(sheets);

// Style sheets that existed in the old sheet list but was excluded in the
// new one.
const removedSheets = /*#__INLINE__*/ diff(oldUniqueSheets, uniqueSheets);
const removedSheets = diff(oldUniqueSheets, uniqueSheets);

removedSheets.forEach((sheet) => {
// Type Note: any removed sheet is already initialized, so there cannot be
// missing adopter for this location.
/*#__INLINE__*/
removeNode(getAdopterByLocation(sheet, self)!);
removeAdopterLocation(sheet, self);
});
Expand Down
7 changes: 0 additions & 7 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ export function rejectImports(contents: string): string {
return _contents.trim();
}

/*#__PURE__*/
export function clearRules(sheet: CSSStyleSheet): void {
for (let i = 0; i < sheet.cssRules.length; i++) {
sheet.deleteRule(0);
}
}

/*#__PURE__*/
export function insertAllRules(from: CSSStyleSheet, to: CSSStyleSheet): void {
forEach.call(from.cssRules, (rule, i) => {
to.insertRule(rule.cssText, i);
Expand All @@ -34,7 +32,6 @@ export function insertAllRules(from: CSSStyleSheet, to: CSSStyleSheet): void {
/**
* Cross-platform check for the element to be connected to the DOM
*/
/*#__PURE__*/
export function isElementConnected(element: Element): boolean {
// If the browser supports web components, it definitely supports
// isConnected. If not, we can just check if the document contains
Expand All @@ -47,22 +44,18 @@ export function isElementConnected(element: Element): boolean {
/**
* Emulates [...new Set(arr)] for older browsers.
*/
/*#__PURE__*/
export function unique<T>(arr: readonly T[]): readonly T[] {
return arr.filter((value, index) => arr.indexOf(value) === index);
}

/*#__PURE__*/
export function diff<T>(arr1: readonly T[], arr2: readonly T[]): readonly T[] {
return arr1.filter((value) => arr2.indexOf(value) === -1);
}

/*#__PURE__*/
export function removeNode(node: Node): void {
node.parentNode!.removeChild(node);
}

/*#__PURE__*/
export function getShadowRoot(element: Element): ShadowRoot | undefined {
return element.shadowRoot || closedShadowRootRegistry.get(element);
}

0 comments on commit 1ae8460

Please sign in to comment.