@webqit/oohtml 2.1.15 → 2.1.17

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 CHANGED
@@ -14,7 +14,7 @@
14
14
  "wicg-proposal"
15
15
  ],
16
16
  "homepage": "https://webqit.io/tooling/oohtml",
17
- "version": "2.1.15",
17
+ "version": "2.1.17",
18
18
  "license": "MIT",
19
19
  "repository": {
20
20
  "type": "git",
@@ -38,10 +38,10 @@
38
38
  "postpublish": "git push && git push --tags"
39
39
  },
40
40
  "dependencies": {
41
- "@webqit/dom": "^2.0.5",
42
- "@webqit/observer": "^2.0.6",
41
+ "@webqit/dom": "^2.0.8",
42
+ "@webqit/observer": "^2.0.7",
43
43
  "@webqit/subscript": "^2.1.39",
44
- "@webqit/util": "^0.8.10"
44
+ "@webqit/util": "^0.8.11"
45
45
  },
46
46
  "devDependencies": {
47
47
  "chai": "^4.3.4",
@@ -34,10 +34,10 @@ export default function init( $config = {} ) {
34
34
  */
35
35
  function realtime( config ) {
36
36
  const window = this, { dom, HTMLImportElement } = window.webqit;
37
- dom.realtime( window.document ).observe( config.import.tagName, record => {
37
+ dom.realtime( window.document ).subtree/*instead of observe(); reason: jsdom timing*/( config.import.tagName, record => {
38
38
  record.entrants.forEach( node => handleRealtime( node, true, record ) );
39
39
  record.exits.forEach( node => handleRealtime( node, false, record ) );
40
- }, { subtree: true, timing: 'sync' } );
40
+ }, { live: true, timing: 'sync' } );
41
41
  function handleRealtime( entry, connectedState, record ) {
42
42
  const elInstance = HTMLImportElement.instance( entry );
43
43
  if ( connectedState ) { elInstance[ '#' ].connectedCallback(); }
@@ -101,7 +101,7 @@ function realtime( config ) {
101
101
  } );
102
102
  };
103
103
  // ------------
104
- dom.realtime( window.document ).observe( [ config.templateSelector, config.ownerContextSelector ], record => {
104
+ dom.realtime( window.document ).subtree/*instead of observe(); reason: jsdom timing*/( [ config.templateSelector, config.ownerContextSelector ], record => {
105
105
  record.entrants.forEach( entry => {
106
106
  if ( entry.matches( config.templateSelector ) ) {
107
107
  Object.defineProperty( entry, 'scoped', { value: entry.hasAttribute( 'scoped' ) } );
@@ -127,5 +127,5 @@ function realtime( config ) {
127
127
  detachImportsContext( entry, true );
128
128
  }
129
129
  } );
130
- }, { subtree: true, timing: 'sync', staticSensitivity: config.staticsensitivity } );
130
+ }, { live: true, timing: 'sync', staticSensitivity: config.staticsensitivity } );
131
131
  }
package/src/index.js CHANGED
@@ -16,9 +16,9 @@ import ScopedJS from './scoped-js/index.js';
16
16
  export default function init( configs = {} ) {
17
17
  if ( !this.webqit ) { this.webqit = {}; }
18
18
  // --------------
19
- BindingsAPI.call(this, ( configs.BINDINGS_API || {} ) );
19
+ BindingsAPI.call( this, ( configs.BINDINGS_API || {} ) );
20
20
  ContextAPI.call( this, ( configs.CONTEXT_API || {} ) );
21
- NamespaceAPI.call(this, ( configs.NAMESPACE_API || {} ) );
21
+ NamespaceAPI.call( this, ( configs.NAMESPACE_API || {} ) );
22
22
  HTMLModules.call( this, ( configs.HTML_MODULES || {} ) );
23
23
  HTMLImports.call( this, ( configs.HTML_IMPORTS || {} ) );
24
24
  ScopedJS.call( this, ( configs.SCOPED_JS || {} ) );
@@ -101,10 +101,10 @@ function realtime( config ) {
101
101
  Observer.deleteProperty( namespaceObj, identifier );
102
102
  }
103
103
  };
104
- dom.realtime( window.document ).observe( config.idSelector, record => {
104
+ dom.realtime( window.document ).subtree/*instead of observe(); reason: jsdom timing*/( config.idSelector, record => {
105
105
  record.entrants.forEach( entry => handle( record.target, entry, true ) );
106
106
  record.exits.forEach( entry => handle( record.target, entry, false ) );
107
- }, { subtree: true, timing: 'sync', staticSensitivity: config.staticsensitivity } );
107
+ }, { live: true, timing: 'sync', staticSensitivity: config.staticsensitivity } );
108
108
  // ----------------
109
109
  if ( config.staticsensitivity ) {
110
110
  dom.realtime( window.document, 'attr' ).observe( config.namespaceSelector, record => {
@@ -29,7 +29,7 @@ export default class Compiler {
29
29
  this.window = window;
30
30
  this.config = config;
31
31
  // This is a global function
32
- window.webqit.oohtml.Script.run = ( execHash ) => {
32
+ window.webqit.oohtml.Script.run = execHash => {
33
33
  const exec = this.constructor.fromHash( execHash );
34
34
  if ( !exec ) throw new Error( `Argument must be a valid exec hash.` );
35
35
  const { script, compiledScript, thisContext } = exec;
@@ -93,7 +93,11 @@ export default class Compiler {
93
93
  cache.set( sourceHash, compiledScript );
94
94
  }
95
95
  const execHash = _static.toHash( { script, compiledScript, thisContext } );
96
- script.textContent = `webqit.oohtml.Script.run('${ execHash }');`;
96
+ if ( script.handling === 'manual' ) {
97
+ webqit.oohtml.Script.run( execHash );
98
+ } else {
99
+ script.textContent = `webqit.oohtml.Script.run( '${ execHash }' );`;
100
+ }
97
101
  }
98
102
 
99
103
  // Match import statements
@@ -27,7 +27,7 @@ export default function init( { advanced = {}, ...$config } ) {
27
27
  return selector.concat( `script${ qualifier }[scoped],script${ qualifier }[contract]` );
28
28
  }, [] ).join( ',' );
29
29
  window.webqit.oohtml.Script = { compileCache: [ new Map, new Map, ] };
30
- window.webqit.SubscriptFunction = $config.SubscriptFunction/* allow for injection, e.g. from test runner */ || SubscriptFunction;
30
+ window.webqit.SubscriptFunction = config.SubscriptFunction/* allow for injection, e.g. from test runner */ || SubscriptFunction;
31
31
  window.webqit.Observer = Observer;
32
32
  realtime.call( window, config );
33
33
  }
@@ -83,18 +83,22 @@ export function execute( compiledScript, thisContext, script ) {
83
83
  */
84
84
  function realtime( config ) {
85
85
  const window = this, { dom } = window.webqit;
86
+ if ( !window.HTMLScriptElement.supports ) { window.HTMLScriptElement.supports = () => false; }
87
+ const potentialManualTypes = [ 'module' ].concat( config.script.mimeType || [] );
86
88
  const compiler = new Compiler( window, config, execute ), handled = () => {};
87
- dom.realtime( window.document ).observe( config.scriptSelector, record => {
89
+ dom.realtime( window.document ).subtree/*instead of observe(); reason: jsdom timing*/( config.scriptSelector, record => {
88
90
  record.entrants.forEach( script => {
89
91
  if ( 'contract' in script ) return handled( script );
90
92
  Object.defineProperty( script, 'contract', { value: script.hasAttribute( 'contract' ) } );
91
93
  if ( 'scoped' in script ) return handled( script );
92
94
  Object.defineProperty( script, 'scoped', { value: script.hasAttribute( 'scoped' ) } );
93
- // ---
95
+ if ( record.type === 'query' || ( potentialManualTypes.includes( script.type ) && !window.HTMLScriptElement.supports( script.type ) ) ) {
96
+ Object.defineProperty( script, 'handling', { value: 'manual' } );
97
+ }
94
98
  const thisContext = script.scoped ? record.target : ( script.type === 'module' ? undefined : window );
95
99
  compiler.compile( script, thisContext );
96
100
  } );
97
- }, { subtree: true, timing: 'intercept', generation: 'entrants' } );
101
+ }, { live: true, timing: 'intercept', generation: 'entrants' } );
98
102
  // ---
99
103
  }
100
104