Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/auto-shadow-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function autoShadowRoot(element: HTMLElement): void {
.attachShadow({
mode: template.getAttribute('data-shadowroot') === 'closed' ? 'closed' : 'open'
})
.appendChild(template.content.cloneNode(true))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ParentNode.append() allows you to also append DOMString objects, whereas Node.appendChild() only accepts Node objects.
  • ParentNode.append() has no return value, whereas Node.appendChild() returns the appended Node object.
  • ParentNode.append() can append several nodes and strings, whereas Node.appendChild() can only append one node.

https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/append

.append(template.content.cloneNode(true))
}
}
}
11 changes: 6 additions & 5 deletions src/bind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function listenForBind(el: Node = document): Subscription {
}
}
})
observer.observe(el, {childList: true, subtree: true, attributes: true, attributeFilter: ['data-action']})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If either options’s attributeOldValue or attributeFilter is present and options’s attributes is omitted, then set options’s attributes to true.

https://dom.spec.whatwg.org/#dom-mutationobserver-observe

observer.observe(el, {childList: true, subtree: true, attributeFilter: ['data-action']})
const subscription = {
get closed() {
return closed
Expand Down Expand Up @@ -94,10 +94,11 @@ function* bindings(el: Element): Iterable<Binding> {
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)
}
}
}

Expand Down