Skip to content

Commit

Permalink
Fix insertAdjacentElement method.
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardocavazza committed Nov 16, 2023
1 parent c9001f4 commit 0bd8cb7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/stale-clocks-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chialab/quantum': patch
---

Fix `insertAdjacentElement` method.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ titleTemplate: Custom elements composition made easy
hero:
name: 'Quantum'
text: ''
tagline: 'Custom elements composition made easy'
tagline: 'Custom elements composition made easy.'
actions:
- theme: brand
text: npm i @chialab/quantum
Expand Down
8 changes: 4 additions & 4 deletions src/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export function extendElement(Element) {
switch (position) {
case 'beforebegin':
if (!parentRealm) {
return /** @type {import('./utils.js').ValueDescriptor} */ (insertAdjacentElement).value.apply(
return /** @type {import('./utils.js').ValueDescriptor} */ (insertAdjacentElement).value.call(
this,
position,
node
Expand All @@ -232,7 +232,7 @@ export function extendElement(Element) {
return parentRealm.insertBefore(this, node);
case 'afterend':
if (!parentRealm) {
return /** @type {import('./utils.js').ValueDescriptor} */ (insertAdjacentElement).value.apply(
return /** @type {import('./utils.js').ValueDescriptor} */ (insertAdjacentElement).value.call(
this,
position,
node
Expand All @@ -241,7 +241,7 @@ export function extendElement(Element) {
return parentRealm.insertBefore(this.nextSibling, node);
case 'afterbegin':
if (!realm) {
return /** @type {import('./utils.js').ValueDescriptor} */ (insertAdjacentElement).value.apply(
return /** @type {import('./utils.js').ValueDescriptor} */ (insertAdjacentElement).value.call(
this,
position,
node
Expand All @@ -250,7 +250,7 @@ export function extendElement(Element) {
return realm.prepend(node);
case 'beforeend':
if (!realm) {
return /** @type {import('./utils.js').ValueDescriptor} */ (insertAdjacentElement).value.apply(
return /** @type {import('./utils.js').ValueDescriptor} */ (insertAdjacentElement).value.call(
this,
position,
node
Expand Down

0 comments on commit 0bd8cb7

Please sign in to comment.