@webqit/oohtml 4.1.1 → 4.1.3

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": "4.1.1",
17
+ "version": "4.1.3",
18
18
  "license": "MIT",
19
19
  "repository": {
20
20
  "type": "git",
@@ -12,7 +12,7 @@ import { _, _init, _toHash, _fromHash } from '../util.js';
12
12
  */
13
13
  export default function init({ advanced = {}, ...$config }) {
14
14
  const { config, window } = _init.call( this, 'scoped-js', $config, {
15
- script: { retention: 'retain', mimeTypes: 'module|text/javascript|application/javascript' },
15
+ script: { retention: 'retain', mimeTypes: 'module|text/javascript|application/javascript', timing: 'auto' },
16
16
  api: { scripts: 'scripts' },
17
17
  advanced: resolveParams(advanced),
18
18
  } );
@@ -71,11 +71,11 @@ async function execute( config, execHash ) {
71
71
  script.textContent = await compiledScript.toString();
72
72
  }
73
73
  // Execute and save state
74
- const documentRoot = script.getRootNode();
75
- if ( !_( documentRoot ).has( 'scriptEnv' ) ) {
76
- _( documentRoot ).set( 'scriptEnv', Object.create( null ) );
74
+ const varScope = script.scoped ? thisContext : script.getRootNode();
75
+ if ( !_( varScope ).has( 'scriptEnv' ) ) {
76
+ _( varScope ).set( 'scriptEnv', Object.create( null ) );
77
77
  }
78
- const state = ( await compiledScript.bind( thisContext, _( documentRoot ).get( 'scriptEnv' ) ) ).execute();
78
+ const state = ( await compiledScript.bind( thisContext, _( varScope ).get( 'scriptEnv' ) ) ).execute();
79
79
  if ( script.quantum ) { Object.defineProperty( script, 'state', { value: state } ); }
80
80
  realdom.realtime( window.document ).observe( script, () => {
81
81
  if ( script.quantum ) { state.dispose(); }
@@ -120,7 +120,7 @@ function realtime( config ) {
120
120
  if ( script.scoped ) { thisContext[ config.api.scripts ].push( script ); }
121
121
  const execHash = _toHash( { script, compiledScript, thisContext } );
122
122
  const manualHandling = record.type === 'query' || ( script.type && !window.HTMLScriptElement.supports( script.type ) );
123
- if ( manualHandling || 1 ) { oohtml.Script.execute( execHash ); } else {
123
+ if ( manualHandling || config.script.timing === 'manual' ) { oohtml.Script.execute( execHash ); } else {
124
124
  script.textContent = `webqit.oohtml.Script.execute( '${ execHash }' );`;
125
125
  }
126
126
  } );