@webqit/oohtml 2.1.50 → 2.1.51
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 +6 -7
- package/dist/html-imports.js +1 -1
- package/dist/html-imports.js.map +2 -2
- package/dist/main.js +12 -12
- package/dist/main.js.map +2 -2
- package/dist/scoped-js.js +6 -6
- package/dist/scoped-js.js.map +2 -2
- package/package.json +1 -1
- package/src/html-imports/_HTMLImportElement.js +6 -2
- package/src/scoped-js/Compiler.js +4 -3
- package/src/scoped-js/index.js +2 -1
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@ import { _ } from '../util.js';
|
|
|
16
16
|
export default function( config ) {
|
|
17
17
|
const window = this, { realdom } = window.webqit;
|
|
18
18
|
const BaseElement = config.import.tagName.includes( '-' ) ? window.HTMLElement : class {};
|
|
19
|
-
|
|
19
|
+
class HTMLImportElement extends BaseElement {
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* @instance
|
|
@@ -27,7 +27,7 @@ export default function( config ) {
|
|
|
27
27
|
*/
|
|
28
28
|
static instance( node ) {
|
|
29
29
|
if ( config.import.tagName.includes( '-' ) && ( node instanceof this ) ) return node;
|
|
30
|
-
return _( node ).get( 'import::instance' ) || new this( node )
|
|
30
|
+
return _( node ).get( 'import::instance' ) || new this( node );
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
@@ -211,4 +211,8 @@ export default function( config ) {
|
|
|
211
211
|
*/
|
|
212
212
|
get slottedElements() { return this[ '#' ].slottedElements; }
|
|
213
213
|
}
|
|
214
|
+
if ( config.import.tagName.includes( '-' ) ) {
|
|
215
|
+
customElements.define( config.import.tagName, HTMLImportElement );
|
|
216
|
+
}
|
|
217
|
+
return HTMLImportElement;
|
|
214
218
|
}
|
|
@@ -56,9 +56,10 @@ export default class Compiler {
|
|
|
56
56
|
const _static = this.constructor;
|
|
57
57
|
const { webqit: { oohtml, ReflexFunction } } = this.window;
|
|
58
58
|
const cache = oohtml.Script.compileCache[ script.reflex ? 0 : 1 ];
|
|
59
|
-
const
|
|
59
|
+
const textContent = ( script._ = script.textContent.trim() ) && script._.startsWith( '/*@oohtml*/if(false){' ) && script._.endsWith( '}/*@oohtml*/' ) ? script._.slice( 21, -12 ) : script.textContent;
|
|
60
|
+
const sourceHash = _static.toHash( textContent );
|
|
60
61
|
// Script instances are parsed only once
|
|
61
|
-
let source =
|
|
62
|
+
let source = textContent, compiledScript;
|
|
62
63
|
if ( !( compiledScript = cache.get( sourceHash ) ) ) {
|
|
63
64
|
// Are there "import" (and "await") statements? Then, we need to rewrite that
|
|
64
65
|
let imports = [], meta = {};
|
|
@@ -85,7 +86,7 @@ export default class Compiler {
|
|
|
85
86
|
? runtimeParams.compileFunction( source )
|
|
86
87
|
: new _FunctionConstructor( source );
|
|
87
88
|
}
|
|
88
|
-
Object.defineProperty( _Function, 'originalSource', { configurable: true, value:
|
|
89
|
+
Object.defineProperty( _Function, 'originalSource', { configurable: true, value: textContent } );
|
|
89
90
|
// Save material function to compile cache
|
|
90
91
|
compiledScript = Object.defineProperty( script.cloneNode(), 'function', { value: _Function } );
|
|
91
92
|
script.scoped && Object.defineProperty( compiledScript, 'scoped', Object.getOwnPropertyDescriptor( script, 'scoped') );
|
package/src/scoped-js/index.js
CHANGED
|
@@ -95,11 +95,12 @@ function realtime( config ) {
|
|
|
95
95
|
const compiler = new Compiler( window, config, execute ), handled = () => {};
|
|
96
96
|
realdom.realtime( window.document ).subtree/*instead of observe(); reason: jsdom timing*/( config.scriptSelector, record => {
|
|
97
97
|
record.entrants.forEach( script => {
|
|
98
|
+
if ( script.cloned ) return;
|
|
98
99
|
if ( 'reflex' in script ) return handled( script );
|
|
99
100
|
Object.defineProperty( script, 'reflex', { value: script.hasAttribute( 'reflex' ) } );
|
|
100
101
|
if ( 'scoped' in script ) return handled( script );
|
|
101
102
|
Object.defineProperty( script, 'scoped', { value: script.hasAttribute( 'scoped' ) } );
|
|
102
|
-
if ( record.type === 'query'
|
|
103
|
+
if ( /*record.type === 'query' ||*/ ( potentialManualTypes.includes( script.type ) && !window.HTMLScriptElement.supports( script.type ) ) ) {
|
|
103
104
|
Object.defineProperty( script, 'handling', { value: 'manual' } );
|
|
104
105
|
}
|
|
105
106
|
const thisContext = script.scoped ? script.parentNode || record.target : ( script.type === 'module' ? undefined : window );
|