export utils as public API

This commit is contained in:
Yanzhen Yu
2020-06-15 17:10:18 +08:00
parent 7feb2c945c
commit 4cf196718c
7 changed files with 16 additions and 11 deletions

View File

@@ -34,7 +34,7 @@ export const mirror: Mirror = {
const id = n.__sn && n.__sn.id;
delete mirror.map[id];
if (n.childNodes) {
n.childNodes.forEach(child =>
n.childNodes.forEach((child) =>
mirror.removeNodeFromMap((child as Node) as INode),
);
}
@@ -53,7 +53,7 @@ export function throttle<T>(
let timeout: number | null = null;
let previous = 0;
// tslint:disable-next-line: only-arrow-functions
return function(arg: T) {
return function (arg: T) {
let now = Date.now();
if (!previous && options.leading === false) {
previous = now;
@@ -83,9 +83,10 @@ export function hookSetter<T>(
key: string | number | symbol,
d: PropertyDescriptor,
isRevoked?: boolean,
win = window,
): hookResetter {
const original = Object.getOwnPropertyDescriptor(target, key);
Object.defineProperty(
const original = win.Object.getOwnPropertyDescriptor(target, key);
win.Object.defineProperty(
target,
key,
isRevoked
@@ -130,7 +131,7 @@ export function isBlocked(node: Node | null, blockClass: blockClass): boolean {
if (typeof blockClass === 'string') {
needBlock = (node as HTMLElement).classList.contains(blockClass);
} else {
(node as HTMLElement).classList.forEach(className => {
(node as HTMLElement).classList.forEach((className) => {
if (blockClass.test(className)) {
needBlock = true;
}