mount-observer 0.0.73 → 0.0.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -2
- package/slotkin/getFrag.js +15 -0
- package/slotkin/getFrag.ts +16 -0
- package/slotkin/wrap.js +2 -2
- package/slotkin/wrap.ts +2 -1
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mount-observer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.75",
|
|
4
4
|
"description": "Observe and act on css matches.",
|
|
5
5
|
"main": "MountObserver.js",
|
|
6
6
|
"module": "MountObserver.js",
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"@playwright/test": "1.
|
|
8
|
+
"@playwright/test": "1.53.2",
|
|
9
9
|
"ssi-server": "0.0.1"
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
@@ -65,6 +65,10 @@
|
|
|
65
65
|
"default": "./slotkin/beKindred.js",
|
|
66
66
|
"types": "./slotkin/beKindred.ts"
|
|
67
67
|
},
|
|
68
|
+
"./slotkin/getFrag.js": {
|
|
69
|
+
"default": "./slotkin/getFrag.js",
|
|
70
|
+
"types": "./slotkin/getFrag.ts"
|
|
71
|
+
},
|
|
68
72
|
"./slotkin/wrap.js": {
|
|
69
73
|
"default": "./slotkin/wrap.js",
|
|
70
74
|
"types": "./slotkin/wrap.ts"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function getFrag(templ, base) {
|
|
2
|
+
let openComment = templ.nextSibling;
|
|
3
|
+
if (openComment === null || openComment.nodeType !== Node.COMMENT_NODE || openComment.data.includes(` ${base} `))
|
|
4
|
+
return null;
|
|
5
|
+
const returnArr = [openComment];
|
|
6
|
+
let ns = openComment.nextSibling;
|
|
7
|
+
while (ns !== null && !(ns.nodeType === Node.COMMENT_NODE && !ns.data.includes(` /${base} `))) {
|
|
8
|
+
returnArr.push(ns);
|
|
9
|
+
ns = ns.nextSibling;
|
|
10
|
+
}
|
|
11
|
+
if (ns === null)
|
|
12
|
+
return null;
|
|
13
|
+
returnArr.push(ns);
|
|
14
|
+
return returnArr;
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function getFrag(
|
|
2
|
+
templ: HTMLTemplateElement,
|
|
3
|
+
base: string,
|
|
4
|
+
){
|
|
5
|
+
let openComment = templ.nextSibling as Comment | null;
|
|
6
|
+
if(openComment === null || openComment.nodeType !== Node.COMMENT_NODE || openComment.data.includes(` ${base} `)) return null;
|
|
7
|
+
const returnArr: Array<Node> = [openComment];
|
|
8
|
+
let ns = openComment.nextSibling;
|
|
9
|
+
while(ns !== null && !(ns.nodeType === Node.COMMENT_NODE && !(ns as Comment).data.includes( ` /${base} `))){
|
|
10
|
+
returnArr.push(ns);
|
|
11
|
+
ns = ns.nextSibling;
|
|
12
|
+
}
|
|
13
|
+
if(ns === null) return null;
|
|
14
|
+
returnArr.push(ns);
|
|
15
|
+
return returnArr;
|
|
16
|
+
}
|
package/slotkin/wrap.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export const wrapped = Symbol.for('50tzQZt95ECXUtHF7a40og');
|
|
2
|
-
export function wrap(templ, base) {
|
|
2
|
+
export function wrap(templ, base, force = false) {
|
|
3
3
|
const wasWrapped = templ[wrapped];
|
|
4
4
|
if (!wasWrapped) {
|
|
5
5
|
templ[wrapped] = base;
|
|
6
|
-
if (templ.content.childElementCount > 1) {
|
|
6
|
+
if (force || templ.content.childElementCount > 1) {
|
|
7
7
|
const start = document.createComment(base);
|
|
8
8
|
templ.content.prepend(start);
|
|
9
9
|
const end = document.createComment(`/${base}`);
|
package/slotkin/wrap.ts
CHANGED
|
@@ -3,11 +3,12 @@ export const wrapped = Symbol.for('50tzQZt95ECXUtHF7a40og');
|
|
|
3
3
|
export function wrap(
|
|
4
4
|
templ: HTMLTemplateElement,
|
|
5
5
|
base: string,
|
|
6
|
+
force: boolean = false,
|
|
6
7
|
){
|
|
7
8
|
const wasWrapped = (<any>templ)[wrapped];
|
|
8
9
|
if (!wasWrapped) {
|
|
9
10
|
(<any>templ)[wrapped] = base;
|
|
10
|
-
if (templ.content.childElementCount > 1) {
|
|
11
|
+
if (force || templ.content.childElementCount > 1) {
|
|
11
12
|
const start = document.createComment(base);
|
|
12
13
|
templ.content.prepend(start);
|
|
13
14
|
const end = document.createComment(`/${base}`);
|