@webqit/oohtml 1.9.4 → 1.9.7
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/dist/html-imports.js +1 -1
- package/dist/html-imports.js.gz +0 -0
- package/dist/html-imports.js.map +1 -1
- package/dist/html-imports.js.map.gz +0 -0
- package/dist/main.js +1 -1
- package/dist/main.js.gz +0 -0
- package/dist/main.js.map +1 -1
- package/dist/main.js.map.gz +0 -0
- package/dist/subscript.js +1 -1
- package/dist/subscript.js.gz +0 -0
- package/dist/subscript.js.map +1 -1
- package/dist/subscript.js.map.gz +0 -0
- package/package.json +2 -2
- package/src/html-imports/index.js +32 -28
- package/src/subscript/Element.js +45 -33
- package/src/subscript/index.js +2 -3
package/dist/subscript.js.map.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"wicg-proposal"
|
|
15
15
|
],
|
|
16
16
|
"homepage": "https://webqit.io/tooling/oohtml",
|
|
17
|
-
"version": "1.9.
|
|
17
|
+
"version": "1.9.7",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@webqit/browser-pie": "^0.0.17",
|
|
42
42
|
"@webqit/observer": "^1.7.5",
|
|
43
|
-
"@webqit/subscript": "^2.0.
|
|
43
|
+
"@webqit/subscript": "^2.0.14",
|
|
44
44
|
"@webqit/util": "^0.8.7",
|
|
45
45
|
"acorn": "^8.7.0"
|
|
46
46
|
},
|
|
@@ -18,7 +18,7 @@ import { config, scopeQuery,
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @init
|
|
21
|
-
*
|
|
21
|
+
*
|
|
22
22
|
* @param Object config
|
|
23
23
|
*/
|
|
24
24
|
export default function init(_config = null, onDomReady = false) {
|
|
@@ -54,6 +54,7 @@ export default function init(_config = null, onDomReady = false) {
|
|
|
54
54
|
// Capture slot elements
|
|
55
55
|
// ----------------------
|
|
56
56
|
|
|
57
|
+
let prev;
|
|
57
58
|
const Import = class/* extends window.HTMLElement*/ {
|
|
58
59
|
|
|
59
60
|
/*
|
|
@@ -67,10 +68,11 @@ export default function init(_config = null, onDomReady = false) {
|
|
|
67
68
|
*/
|
|
68
69
|
|
|
69
70
|
static create(el) {
|
|
70
|
-
return new Import(el);
|
|
71
|
+
return _internals(this.el, 'oohtml').get('instance') || new Import(el);
|
|
71
72
|
}
|
|
72
73
|
constructor(importEl) {
|
|
73
74
|
this.el = importEl;
|
|
75
|
+
_internals(this.el, 'oohtml').set('instance', this);
|
|
74
76
|
const [ importID, modifiers ] = parseScopeReferenceExpr(importEl.getAttribute(_meta.get('attr.importid')) || 'default');
|
|
75
77
|
_internals(this.el, 'oohtml').set('importID', importID);
|
|
76
78
|
_internals(this.el, 'oohtml').set('importModifiers', modifiers);
|
|
@@ -413,33 +415,35 @@ export default function init(_config = null, onDomReady = false) {
|
|
|
413
415
|
const hydrateSlots = () => {
|
|
414
416
|
_arrFrom(document.querySelectorAll(exportgroupSelector)).forEach(_export => {
|
|
415
417
|
// Scan
|
|
416
|
-
if (
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
418
|
+
if (_internals(_export.parentNode, 'oohtml').get('importsCan')) return;
|
|
419
|
+
// hydrateSlots() might be running AFTER certain <slots> have resolved
|
|
420
|
+
// and _export might be a just-resolved node
|
|
421
|
+
if (_export.importReference) return;
|
|
422
|
+
var slottedElements = [];
|
|
423
|
+
_export.parentNode.childNodes.forEach(node => {
|
|
424
|
+
var nodeValue;
|
|
425
|
+
if (node.nodeType === 1/** ELEMENT_NODE */ && node.matches(exportgroupSelector)) {
|
|
426
|
+
slottedElements.push(node);
|
|
427
|
+
} else if (node.nodeType === 8/** COMMENT_NODE */ && (nodeValue = node.nodeValue.trim())
|
|
428
|
+
&& nodeValue.startsWith('<' + _meta.get('element.import'))
|
|
429
|
+
&& nodeValue.endsWith('</' + _meta.get('element.import') + '>')) {
|
|
430
|
+
var importEl, reviver = document.createElement('div');
|
|
431
|
+
reviver.innerHTML = nodeValue;
|
|
432
|
+
if ((importEl = reviver.firstChild).matches(_meta.get('element.import'))) {
|
|
433
|
+
// Belongs to a composition block?
|
|
434
|
+
var compositionBlock = !importEl.hasAttribute(_meta.get('attr.moduleref'))
|
|
435
|
+
? node.parentNode.closest(modulerefSelector) : (
|
|
436
|
+
importEl.getAttribute(_meta.get('attr.moduleref')).trim().startsWith('~') ? node.parentNode.closest(exportgroupSelector) : null
|
|
437
|
+
)
|
|
438
|
+
var importElInstance = Import.create(importEl);
|
|
439
|
+
importElInstance.hydrate(node, slottedElements, compositionBlock);
|
|
440
|
+
// Empty basket
|
|
441
|
+
slottedElements = [];
|
|
438
442
|
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
// Scanning is once for every parent
|
|
446
|
+
_internals(_export.parentNode, 'oohtml').set('importsCan', true);
|
|
443
447
|
});
|
|
444
448
|
};
|
|
445
449
|
|
package/src/subscript/Element.js
CHANGED
|
@@ -17,21 +17,21 @@ export const Element = BaseElement => class extends BaseElement {
|
|
|
17
17
|
* @subscript Element
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
static get subscriptMethods() {
|
|
21
|
-
return [ 'render' ];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
20
|
static get subscriptParams() {
|
|
25
21
|
return { globalsAutoObserve: [ 'document' ] };
|
|
26
22
|
}
|
|
27
23
|
|
|
24
|
+
static get subscriptMethods() {
|
|
25
|
+
return [ 'render' ];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
28
|
static implement( element, subscriptFunction ) {
|
|
29
|
-
let
|
|
29
|
+
let subscripts = _internals( element, 'oohtml', 'subscripts' );
|
|
30
30
|
let id = subscriptFunction.name;
|
|
31
31
|
if ( !id ) {
|
|
32
|
-
id = [ ...
|
|
32
|
+
id = [ ...subscripts.keys() ].filter( k => _isNumeric( k ) ).length;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
subscripts.set( id, subscriptFunction );
|
|
35
35
|
return subscriptFunction;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -47,6 +47,40 @@ export const Element = BaseElement => class extends BaseElement {
|
|
|
47
47
|
return this.implement( element, Subscript.clone( method, element ) );
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @disconnectedCallback()
|
|
52
|
+
*/
|
|
53
|
+
static doConnectedCallback( instance ) {
|
|
54
|
+
if ( ( typeof WebQit === 'undefined' ) || !WebQit.Observer ) return;
|
|
55
|
+
const subscripts = _internals( instance, 'oohtml', 'subscripts' );
|
|
56
|
+
const signals = ( mutations, evt, namespace = [] ) => {
|
|
57
|
+
subscripts.forEach( api => api.thread( ...mutations.map( mu => namespace.concat( mu.path ) ) ) );
|
|
58
|
+
};
|
|
59
|
+
( this.subscriptParams.globalsAutoObserve || [] ).forEach( identifier => {
|
|
60
|
+
WebQit.Observer.observe( globalThis[ identifier ], mutations => signals( mutations, null, [ identifier ] ), {
|
|
61
|
+
subtree: true, diff: true, tags: [ instance, 'subscript-element', identifier ], unique: true
|
|
62
|
+
} );
|
|
63
|
+
} );
|
|
64
|
+
WebQit.Observer.observe( instance, mutations => signals( mutations, null, [ 'this' ] ), {
|
|
65
|
+
subtree: true, diff: true, tags: [ instance, 'subscript-element', 'this' ], unique: true
|
|
66
|
+
} );
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @disconnectedCallback()
|
|
71
|
+
*/
|
|
72
|
+
static doDisconnectedCallback( instance ) {
|
|
73
|
+
if ( ( typeof WebQit === 'undefined' ) || !WebQit.Observer ) return;
|
|
74
|
+
( this.subscriptParams.globalsAutoObserve || [] ).forEach( identifier => {
|
|
75
|
+
WebQit.Observer.unobserve( globalThis[ identifier ], null, null, {
|
|
76
|
+
subtree: true, tags: [ instance, 'subscript-element', identifier ]
|
|
77
|
+
} );
|
|
78
|
+
} );
|
|
79
|
+
WebQit.Observer.unobserve( instance, null, null, {
|
|
80
|
+
subtree: true, tags: [ instance, 'subscript-element', 'this' ]
|
|
81
|
+
} );
|
|
82
|
+
}
|
|
83
|
+
|
|
50
84
|
/**
|
|
51
85
|
* @constructor()
|
|
52
86
|
*/
|
|
@@ -58,27 +92,13 @@ export const Element = BaseElement => class extends BaseElement {
|
|
|
58
92
|
let proxy = subscriptConstructor.implementMethod( this, this[ methodName ] );
|
|
59
93
|
this[ methodName ] = proxy;
|
|
60
94
|
} );
|
|
61
|
-
if ( ( typeof WebQit === 'undefined' ) || !WebQit.Observer ) return;
|
|
62
|
-
( subscriptConstructor.subscriptParams.globalsAutoObserve || [] ).forEach( identifier => {
|
|
63
|
-
WebQit.Observer.link( globalThis, identifier, globalThis[ identifier ] );
|
|
64
|
-
} );
|
|
65
95
|
}
|
|
66
96
|
|
|
67
97
|
/**
|
|
68
98
|
* @connectedCallback()
|
|
69
99
|
*/
|
|
70
100
|
connectedCallback() {
|
|
71
|
-
|
|
72
|
-
const signals = ( mutations, evt, namespace = [] ) => {
|
|
73
|
-
let subscriptConsole = _internals( this, 'oohtml', 'subscript', 'console' );
|
|
74
|
-
subscriptConsole.forEach( api => api.thread( ...mutations.map( mu => namespace.concat( mu.path ) ) ) );
|
|
75
|
-
};
|
|
76
|
-
WebQit.Observer.observe( globalThis, signals, {
|
|
77
|
-
subtree: true, tags: [ this, 'subscript-element', 'globals' ], unique: true
|
|
78
|
-
} );
|
|
79
|
-
WebQit.Observer.observe( this, mutations => signals( mutations, null, [ 'this' ] ), {
|
|
80
|
-
subtree: true, tags: [ this, 'subscript-element', 'this' ], unique: true
|
|
81
|
-
} );
|
|
101
|
+
this.constructor.doConnectedCallback( this );
|
|
82
102
|
if ( super.connectedCallback ) {
|
|
83
103
|
super.connectedCallback();
|
|
84
104
|
}
|
|
@@ -88,22 +108,14 @@ export const Element = BaseElement => class extends BaseElement {
|
|
|
88
108
|
* @disconnectedCallback()
|
|
89
109
|
*/
|
|
90
110
|
disconnectedCallback() {
|
|
91
|
-
|
|
92
|
-
subscriptConsole.forEach( api => api.dispose() );
|
|
93
|
-
if ( ( typeof WebQit === 'undefined' ) || !WebQit.Observer ) return;
|
|
94
|
-
WebQit.Observer.unobserve( globalThis, null, null, {
|
|
95
|
-
subtree: true, tags: [ this, 'subscript-element', 'globals' ]
|
|
96
|
-
} );
|
|
97
|
-
WebQit.Observer.unobserve( this, null, null, {
|
|
98
|
-
subtree: true, tags: [ this, 'subscript-element', 'this' ]
|
|
99
|
-
} );
|
|
111
|
+
this.constructor.doDisconnectedCallback( this );
|
|
100
112
|
if ( super.disconnectedCallback ) {
|
|
101
113
|
super.disconnectedCallback();
|
|
102
114
|
}
|
|
103
115
|
}
|
|
104
116
|
|
|
105
|
-
get
|
|
106
|
-
return _internals( this, 'oohtml', '
|
|
117
|
+
get subscripts() {
|
|
118
|
+
return _internals( this, 'oohtml', 'subscripts' );
|
|
107
119
|
}
|
|
108
120
|
|
|
109
121
|
/**
|
package/src/subscript/index.js
CHANGED
|
@@ -30,7 +30,6 @@ export default function init( _config = null, onDomReady = false ) {
|
|
|
30
30
|
}, _config );
|
|
31
31
|
|
|
32
32
|
const subscriptElement = Element( class {} );
|
|
33
|
-
const $subscriptElement = new subscriptElement;
|
|
34
33
|
mutations.onPresent( _meta.get('selectors.script'), scriptElement => {
|
|
35
34
|
|
|
36
35
|
let ownerNode = scriptElement.parentNode;
|
|
@@ -43,11 +42,11 @@ export default function init( _config = null, onDomReady = false ) {
|
|
|
43
42
|
if ( embeds.has( scriptElement ) ) return;
|
|
44
43
|
|
|
45
44
|
subscriptElement.implementScript( ownerNode, scriptElement )();
|
|
46
|
-
|
|
45
|
+
subscriptElement.doConnectedCallback( ownerNode );
|
|
47
46
|
embeds.add( scriptElement );
|
|
48
47
|
|
|
49
48
|
let mo = mutations.onRemoved( ownerNode, () => {
|
|
50
|
-
|
|
49
|
+
subscriptElement.doDisconnectedCallback( ownerNode );
|
|
51
50
|
embeds.delete( scriptElement );
|
|
52
51
|
mo.disconnect();
|
|
53
52
|
}, { ignoreTransients: true });
|