@webqit/oohtml 2.1.39 → 2.1.41
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/README.md +5 -7
- package/dist/html-imports.js +1 -1
- package/dist/html-imports.js.map +2 -2
- package/dist/main.js +11 -11
- package/dist/main.js.map +2 -2
- package/package.json +1 -1
- package/src/html-imports/_HTMLExportsManager.js +7 -7
- package/src/html-imports/_HTMLImportElement.js +8 -8
- package/src/html-imports/index.js +7 -8
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ export default class _HTMLExportsManager {
|
|
|
27
27
|
this.parent = parent;
|
|
28
28
|
this.level = level;
|
|
29
29
|
this.modules = getModulesObject( this.host );
|
|
30
|
-
this.exportId = ( this.host.getAttribute( this.config.template?.attr.
|
|
30
|
+
this.exportId = ( this.host.getAttribute( this.config.template?.attr.moduledef ) || '' ).trim();
|
|
31
31
|
this.validateExportId( this.exportId );
|
|
32
32
|
const realdom = this.window.webqit.realdom;
|
|
33
33
|
// ----------
|
|
@@ -71,15 +71,15 @@ export default class _HTMLExportsManager {
|
|
|
71
71
|
export( entries, isConnected ) {
|
|
72
72
|
entries.forEach( entry => {
|
|
73
73
|
if ( entry.nodeType !== 1 ) return;
|
|
74
|
-
const
|
|
74
|
+
const isTemplate = entry.matches( this.config.templateSelector );
|
|
75
|
+
const exportId = ( entry.getAttribute( isTemplate ? this.config.template.attr.moduledef : this.config.template.attr.fragmentdef ) || '' ).trim();
|
|
75
76
|
if ( !exportId ) return;
|
|
76
|
-
const isPackage = entry.matches( this.config.templateSelector );
|
|
77
77
|
if ( isConnected ) {
|
|
78
|
-
if (
|
|
79
|
-
Observer.set( this.modules, ( !
|
|
78
|
+
if ( isTemplate ) { new _HTMLExportsManager( this.window, entry, this.config, this.host, this.level + 1 ); }
|
|
79
|
+
Observer.set( this.modules, ( !isTemplate && '#' || '' ) + exportId, entry );
|
|
80
80
|
} else {
|
|
81
|
-
if (
|
|
82
|
-
Observer.deleteProperty( this.modules, ( !
|
|
81
|
+
if ( isTemplate ) { _HTMLExportsManager.instance( this.window, entry ).dispose(); }
|
|
82
|
+
Observer.deleteProperty( this.modules, ( !isTemplate && '#' || '' ) + exportId );
|
|
83
83
|
}
|
|
84
84
|
} );
|
|
85
85
|
}
|
|
@@ -68,12 +68,12 @@ export default function( config ) {
|
|
|
68
68
|
} );
|
|
69
69
|
// ----------------
|
|
70
70
|
priv.hydrationImportRequest = new AbortController;
|
|
71
|
-
priv.importRequest(
|
|
72
|
-
if ( priv.originalsRemapped ) { return this.fill(
|
|
73
|
-
const identifiersMap =
|
|
71
|
+
priv.importRequest( fragments => {
|
|
72
|
+
if ( priv.originalsRemapped ) { return this.fill( fragments ); }
|
|
73
|
+
const identifiersMap = fragments.map( fragment => ( { el: fragment, fragmentDef: fragment.getAttribute( config.template.attr.fragmentdef ) || '', tagName: fragment.tagName, } ) );
|
|
74
74
|
slottedElements.forEach( slottedElement => {
|
|
75
|
-
const tagName = slottedElement.tagName,
|
|
76
|
-
const originalsMatch = identifiersMap.filter(
|
|
75
|
+
const tagName = slottedElement.tagName, fragmentDef = slottedElement.getAttribute( config.template.attr.fragmentdef ) || '';
|
|
76
|
+
const originalsMatch = identifiersMap.filter( fragmentIdentifiers => tagName === fragmentIdentifiers.tagName && fragmentDef === fragmentIdentifiers.fragmentDef );
|
|
77
77
|
if ( originalsMatch.length !== 1 ) return;
|
|
78
78
|
_( slottedElement ).set( 'original@imports', originalsMatch[ 0 ].el );
|
|
79
79
|
} );
|
|
@@ -112,7 +112,7 @@ export default function( config ) {
|
|
|
112
112
|
priv.moduleRefRealtime = realdom.realtime( this.el ).attr( config.import.attr.moduleref, ( record, { signal } ) => {
|
|
113
113
|
priv.moduleRef = record.value;
|
|
114
114
|
// Below, we ignore first restore from hydration
|
|
115
|
-
priv.importRequest(
|
|
115
|
+
priv.importRequest( fragments => !priv.hydrationImportRequest && this.fill( fragments ), signal );
|
|
116
116
|
}, { live: true, timing: 'sync', lifecycleSignals: true } );
|
|
117
117
|
// Must come after
|
|
118
118
|
priv.hydrationImportRequest?.abort();
|
|
@@ -170,8 +170,8 @@ export default function( config ) {
|
|
|
170
170
|
// Clone each slottable element and give it a reference to its original
|
|
171
171
|
const slottableElementClone = slottableElement.cloneNode( true );
|
|
172
172
|
// The folllowing references must be set before adding to DODM
|
|
173
|
-
if ( !slottableElementClone.hasAttribute( config.
|
|
174
|
-
slottableElementClone.toggleAttribute( config.
|
|
173
|
+
if ( !slottableElementClone.hasAttribute( config.template.attr.fragmentdef ) ) {
|
|
174
|
+
slottableElementClone.toggleAttribute( config.template.attr.fragmentdef, true );
|
|
175
175
|
}
|
|
176
176
|
_( slottableElementClone ).set( 'original@imports', slottableElement );
|
|
177
177
|
_( slottableElementClone ).set( 'slot@imports', this.el );
|
|
@@ -18,16 +18,15 @@ import { _, _init } from '../util.js';
|
|
|
18
18
|
*/
|
|
19
19
|
export default function init( $config = {} ) {
|
|
20
20
|
const { config, realdom, window } = _init.call( this, 'html-imports', $config, {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
context: { attr: { importscontext: 'importscontext', contextname: 'contextname' }, api: { modules: 'modules' }, },
|
|
21
|
+
template: { attr: { moduledef: 'def', fragmentdef: 'def', extends: 'extends', inherits: 'inherits' }, api: { modules: 'modules', moduledef: 'def' }, },
|
|
22
|
+
context: { attr: { importscontext: 'importscontext', contextname: 'contextname' }, api: { import: 'import' }, },
|
|
24
23
|
import: { tagName: 'import', attr: { moduleref: 'ref' }, },
|
|
25
24
|
staticsensitivity: true,
|
|
26
25
|
isomorphic: true,
|
|
27
26
|
} );
|
|
28
|
-
config.templateSelector = `template[${ window.CSS.escape( config.template.attr.
|
|
27
|
+
config.templateSelector = `template[${ window.CSS.escape( config.template.attr.moduledef ) }]`;
|
|
29
28
|
config.ownerContextSelector = [ config.context.attr.contextname, config.context.attr.importscontext ].map( a => `[${ window.CSS.escape( a ) }]` ).join( ',' );
|
|
30
|
-
config.slottedElementsSelector = `[${ window.CSS.escape( config.
|
|
29
|
+
config.slottedElementsSelector = `[${ window.CSS.escape( config.template.attr.fragmentdef ) }]`;
|
|
31
30
|
window.webqit.HTMLImportElement = _HTMLImportElement.call( window, config );
|
|
32
31
|
window.webqit.HTMLImportsProvider = class extends _HTMLImportsProvider {
|
|
33
32
|
static get config() { return config; }
|
|
@@ -67,15 +66,15 @@ function exposeModulesObjects( config ) {
|
|
|
67
66
|
const window = this;
|
|
68
67
|
// Assertions
|
|
69
68
|
if ( config.template.api.modules in window.HTMLTemplateElement.prototype ) { throw new Error( `The "HTMLTemplateElement" class already has a "${ config.template.api.modules }" property!` ); }
|
|
70
|
-
if ( config.template.api.
|
|
69
|
+
if ( config.template.api.moduledef in window.HTMLTemplateElement.prototype ) { throw new Error( `The "HTMLTemplateElement" class already has a "${ config.template.api.moduledef }" property!` ); }
|
|
71
70
|
if ( config.context.api.import in window.document ) { throw new Error( `document already has a "${ config.context.api.import }" property!` ); }
|
|
72
71
|
if ( config.context.api.import in window.HTMLElement.prototype ) { throw new Error( `The "HTMLElement" class already has a "${ config.context.api.import }" property!` ); }
|
|
73
72
|
// Definitions
|
|
74
73
|
Object.defineProperty( window.HTMLTemplateElement.prototype, config.template.api.modules, { get: function() {
|
|
75
74
|
return getModulesObject( this );
|
|
76
75
|
} } );
|
|
77
|
-
Object.defineProperty( window.HTMLTemplateElement.prototype, config.template.api.
|
|
78
|
-
return this.getAttribute( config.template.attr.
|
|
76
|
+
Object.defineProperty( window.HTMLTemplateElement.prototype, config.template.api.moduledef, { get: function() {
|
|
77
|
+
return this.getAttribute( config.template.attr.moduledef );
|
|
79
78
|
} } );
|
|
80
79
|
Object.defineProperty( window.document, config.context.api.import, { value: function( ref, callback, options = {} ) {
|
|
81
80
|
return importRequest( window.document, ref, callback, options );
|