Skip to content

Commit

Permalink
Minor: Removing dependencies to 'svelte/internal' (helps with Svelte …
Browse files Browse the repository at this point in the history
…v5 compatibility, re: issue #25)
  • Loading branch information
patricknelson committed Nov 28, 2023
1 parent caab927 commit 3843459
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"url": "git+ssh://git@github.com/patricknelson/svelte-retag.git"
},
"peerDependencies": {
"svelte": "^3.19.0 || ^4.0.0-next.0"
"svelte": "^3.19.0 || ^4.0.0"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0",
Expand Down
30 changes: 27 additions & 3 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,31 @@
* level information, i.e. they do not call "this").
*/

import { detach, insert, noop } from 'svelte/internal';

/**
* Extracted from svelte's internal API @ src/runtime/internal/dom.js
*
* @param {Node} target
* @param {Node} node
* @param {Node} [anchor]
* @returns {void}
*/
function insert(target, node, anchor) {
target.insertBefore(node, anchor || null);
}


/**
* Extracted from svelte's internal API @ src/runtime/internal/dom.js
*
* @param {Node} node
* @returns {void}
*/
function detach(node) {
if (node.parentNode) {
node.parentNode.removeChild(node);
}
}


/**
Expand All @@ -22,7 +46,7 @@ export function createSvelteSlots(slots) {
function createSlotFn(element) {
return function() {
return {
c: noop,
c: function() {}, // noop
m: function mount(target, anchor) {
insert(target, element.cloneNode(true), anchor);
},
Expand All @@ -31,7 +55,7 @@ export function createSvelteSlots(slots) {
detach(element);
}
},
l: noop,
l: function() {}, // noop
};
};
}
Expand Down

0 comments on commit 3843459

Please sign in to comment.