From 2522a5a344b6c89256529b7ea65c579f9257b077 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Mon, 25 Jan 2021 09:03:23 +0000 Subject: [PATCH 1/3] refactor(auto-shadow-root): use append over appendChild --- src/auto-shadow-root.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auto-shadow-root.ts b/src/auto-shadow-root.ts index 2b0d191d..c30fb0e7 100644 --- a/src/auto-shadow-root.ts +++ b/src/auto-shadow-root.ts @@ -5,7 +5,7 @@ export function autoShadowRoot(element: HTMLElement): void { .attachShadow({ mode: template.getAttribute('data-shadowroot') === 'closed' ? 'closed' : 'open' }) - .appendChild(template.content.cloneNode(true)) + .append(template.content.cloneNode(true)) } } } From f4bed31cd990cf55375ce46b3bda9ba1f2d5da6e Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Mon, 25 Jan 2021 09:04:30 +0000 Subject: [PATCH 2/3] refactor(bind): inline object properties, avoiding consts --- src/bind.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bind.ts b/src/bind.ts index d19d7576..8eb01b5c 100644 --- a/src/bind.ts +++ b/src/bind.ts @@ -94,10 +94,11 @@ function* bindings(el: Element): Iterable { for (const action of (el.getAttribute('data-action') || '').trim().split(/\s+/)) { const eventSep = action.lastIndexOf(':') const methodSep = action.lastIndexOf('#') - const type = action.slice(0, eventSep) - const tag = action.slice(eventSep + 1, methodSep) - const method = action.slice(methodSep + 1) - yield {type, tag, method} + yield { + type: action.slice(0, eventSep), + tag: action.slice(eventSep + 1, methodSep), + method: action.slice(methodSep + 1) + } } } From 6d70fe577e159cd881e468ad1df8c516017ba56b Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Mon, 25 Jan 2021 09:43:35 +0000 Subject: [PATCH 3/3] refactor(bind): remove attributes property, this is implied with `attributeFilter` --- src/bind.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bind.ts b/src/bind.ts index 8eb01b5c..fcb1b8a0 100644 --- a/src/bind.ts +++ b/src/bind.ts @@ -38,7 +38,7 @@ export function listenForBind(el: Node = document): Subscription { } } }) - observer.observe(el, {childList: true, subtree: true, attributes: true, attributeFilter: ['data-action']}) + observer.observe(el, {childList: true, subtree: true, attributeFilter: ['data-action']}) const subscription = { get closed() { return closed