@webqit/oohtml 4.3.17 → 4.4.0
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/bindings-api.js +1 -1
- package/dist/bindings-api.js.map +3 -3
- package/dist/context-api.js +1 -1
- package/dist/context-api.js.map +3 -3
- package/dist/data-binding.js +6 -6
- package/dist/data-binding.js.map +3 -3
- package/dist/html-imports.js +1 -1
- package/dist/html-imports.js.map +3 -3
- package/dist/main.js +22 -22
- package/dist/main.js.map +3 -3
- package/dist/main.lite.js +16 -16
- package/dist/main.lite.js.map +3 -3
- package/dist/namespaced-html.js +1 -1
- package/dist/namespaced-html.js.map +3 -3
- package/dist/scoped-css.js +3 -3
- package/dist/scoped-css.js.map +3 -3
- package/dist/scoped-js.js +1 -1
- package/dist/scoped-js.js.map +3 -3
- package/package.json +4 -4
- package/src/bindings-api/index.js +4 -4
- package/src/context-api/DOMContexts.js +3 -3
- package/src/data-binding/index.js +18 -18
- package/src/html-imports/HTMLImportsContext.js +1 -1
- package/src/html-imports/HTMLModule.js +4 -4
- package/src/html-imports/_HTMLImportElement.js +10 -10
- package/src/html-imports/index.js +5 -5
- package/src/namespaced-html/index.js +15 -15
- package/src/scoped-js/index.js +4 -4
- package/src/util.js +6 -6
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.
|
|
17
|
+
"version": "4.4.0",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"postpublish": "git push && git push --tags"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@webqit/quantum-js": "^4.5.
|
|
43
|
-
"@webqit/realdom": "^2.1.
|
|
44
|
-
"@webqit/util": "^0.8.
|
|
42
|
+
"@webqit/quantum-js": "^4.5.30",
|
|
43
|
+
"@webqit/realdom": "^2.1.34",
|
|
44
|
+
"@webqit/util": "^0.8.16"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@webqit/oohtml-ssr": "^2.1.1",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @imports
|
|
4
4
|
*/
|
|
5
5
|
import DOMBindingsContext from './DOMBindingsContext.js';
|
|
6
|
-
import {
|
|
6
|
+
import { _wq, _init, _splitOuter } from '../util.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @init
|
|
@@ -28,9 +28,9 @@ export default function init( $config = {} ) {
|
|
|
28
28
|
*/
|
|
29
29
|
function getBindings( config, node ) {
|
|
30
30
|
const window = this, { webqit: { Observer, oohtml: { configs: { CONTEXT_API: ctxConfig } } } } = window;
|
|
31
|
-
if ( !
|
|
31
|
+
if ( !_wq( node ).has( 'bindings' ) ) {
|
|
32
32
|
const bindingsObj = Object.create( null );
|
|
33
|
-
|
|
33
|
+
_wq( node ).set( 'bindings', bindingsObj );
|
|
34
34
|
Observer.observe( bindingsObj, mutations => {
|
|
35
35
|
if ( node instanceof window.Element ) {
|
|
36
36
|
const bindingsParse = parseBindingsAttr( node.getAttribute( config.attr.bindingsreflection ) || '' );
|
|
@@ -57,7 +57,7 @@ function getBindings( config, node ) {
|
|
|
57
57
|
}
|
|
58
58
|
} );
|
|
59
59
|
}
|
|
60
|
-
return
|
|
60
|
+
return _wq( node ).get( 'bindings' );
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
@@ -15,15 +15,15 @@ export default class DOMContexts {
|
|
|
15
15
|
* @instance
|
|
16
16
|
*/
|
|
17
17
|
static instance( host ) {
|
|
18
|
-
return
|
|
18
|
+
return _wq( host ).get( 'contexts::instance' ) || new this( host );;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* @constructor
|
|
23
23
|
*/
|
|
24
24
|
constructor( host ) {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
_wq( host ).get( `contexts::instance` )?.dispose();
|
|
26
|
+
_wq( host ).set( `contexts::instance`, this );
|
|
27
27
|
const priv = { host, contexts: new Set };
|
|
28
28
|
Object.defineProperty( this, '#', { get: () => priv } );
|
|
29
29
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveParams } from '@webqit/quantum-js/params';
|
|
2
2
|
import { xpathQuery } from '@webqit/realdom/src/realtime/Util.js';
|
|
3
|
-
import {
|
|
3
|
+
import { _wq, _init, _splitOuter } from '../util.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Initializes DOM Parts.
|
|
@@ -58,7 +58,7 @@ function realtime( config ) {
|
|
|
58
58
|
|
|
59
59
|
function createDynamicScope( config, root ) {
|
|
60
60
|
const { webqit: { realdom, Observer, DOMBindingsContext } } = this;
|
|
61
|
-
if (
|
|
61
|
+
if ( _wq( root ).has( 'data-binding' ) ) return _wq( root ).get( 'data-binding' );
|
|
62
62
|
const scope = Object.create( null ), abortController = new AbortController;
|
|
63
63
|
scope[ '$exec__' ] = ( target, prop, ...args ) => {
|
|
64
64
|
const exec = () => {
|
|
@@ -87,21 +87,21 @@ function createDynamicScope( config, root ) {
|
|
|
87
87
|
has: ( e, recieved, next ) => { return next( true ); }
|
|
88
88
|
} );
|
|
89
89
|
const instance = { scope, abortController, bindings: new Map };
|
|
90
|
-
|
|
90
|
+
_wq( root ).set( 'data-binding', instance );
|
|
91
91
|
return instance;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
function cleanup( ...entries ) {
|
|
95
95
|
for ( const node of entries ) {
|
|
96
96
|
const root = node.nodeName === '#text' ? node.parentNode : node;
|
|
97
|
-
const { bindings, abortController } =
|
|
97
|
+
const { bindings, abortController } = _wq( root ).get( 'data-binding' ) || {};
|
|
98
98
|
if ( !bindings?.has( node ) ) return;
|
|
99
99
|
bindings.get( node ).state.dispose();
|
|
100
100
|
bindings.get( node ).signals?.forEach( s => s.abort() );
|
|
101
101
|
bindings.delete( node );
|
|
102
102
|
if ( !bindings.size ) {
|
|
103
103
|
abortController.abort();
|
|
104
|
-
|
|
104
|
+
_wq( root ).delete( 'data-binding' );
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -155,8 +155,8 @@ const discreteParseCache = new Map;
|
|
|
155
155
|
function compileDiscreteBindings( config, str ) {
|
|
156
156
|
if ( discreteParseCache.has( str ) ) return discreteParseCache.get( str );
|
|
157
157
|
let source = `let content = ((${ str }) ?? '') + '';`;
|
|
158
|
-
source += `$
|
|
159
|
-
source += `if ( this.$oohtml_internal_databinding_anchorNode ) { $
|
|
158
|
+
source += `$assign__wq(this, 'nodeValue', content);`;
|
|
159
|
+
source += `if ( this.$oohtml_internal_databinding_anchorNode ) { $assign__wq(this.$oohtml_internal_databinding_anchorNode, 'nodeValue', "${ config.tokens.tagStart }${ escDouble( str ) }${ config.tokens.stateStart }" + content.length + "${ config.tokens.stateEnd } ${ config.tokens.tagEnd }"); }`;
|
|
160
160
|
const { webqit: { QuantumModule } } = this;
|
|
161
161
|
const { parserParams, compilerParams, runtimeParams } = config.advanced;
|
|
162
162
|
const compiled = new QuantumModule( source, { parserParams, compilerParams, runtimeParams } );
|
|
@@ -189,22 +189,22 @@ function compileInlineBindings( config, str ) {
|
|
|
189
189
|
const arg = `(${ right })`, $arg = `(${ arg } ?? '')`;
|
|
190
190
|
// CSS
|
|
191
191
|
if ( directive === '&' ) {
|
|
192
|
-
if ( param.startsWith( '--' ) ) return `$
|
|
193
|
-
return `$
|
|
192
|
+
if ( param.startsWith( '--' ) ) return `$exec__wq(this.style, 'setProperty', "${ escDouble( param ) }", ${ $arg });`;
|
|
193
|
+
return `$assign__wq(this.style, "${ escDouble( param ) }", ${ $arg });`;
|
|
194
194
|
}
|
|
195
195
|
// Class list
|
|
196
|
-
if ( directive === '%' ) return `$
|
|
196
|
+
if ( directive === '%' ) return `$exec__wq(this.classList, 'toggle', "${ escDouble( param ) }", !!${ arg });`;
|
|
197
197
|
// Attribute
|
|
198
198
|
if ( directive === '~' ) {
|
|
199
|
-
if ( param.startsWith( '?' ) ) return `$
|
|
200
|
-
return `$
|
|
199
|
+
if ( param.startsWith( '?' ) ) return `$exec__wq(this, 'toggleAttribute', "${ escDouble( param.substring( 1 ).trim() ) }", !!${ arg });`;
|
|
200
|
+
return `$exec__wq(this, 'setAttribute', "${ escDouble( param ) }", ${ $arg });`;
|
|
201
201
|
}
|
|
202
202
|
// Structure
|
|
203
203
|
if ( directive === '#' ) {
|
|
204
204
|
if ( validation[ param ] ) throw new Error( `Duplicate binding: ${ left }.` );
|
|
205
205
|
validation[ param ] = true;
|
|
206
|
-
if ( param === 'text' ) return `$
|
|
207
|
-
if ( param === 'html' ) return `$
|
|
206
|
+
if ( param === 'text' ) return `$assign__wq(this, 'textContent', ${ $arg });`;
|
|
207
|
+
if ( param === 'html' ) return `$assign__wq(this, 'innerHTML', ${ $arg });`;
|
|
208
208
|
if ( param === 'items' ) {
|
|
209
209
|
const [ iterationSpec, importSpec ] = _splitOuter( right, '/' );
|
|
210
210
|
if ( !importSpec ) throw new Error( `Invalid ${ directive }items spec: ${ str }; no import specifier.` );
|
|
@@ -235,12 +235,12 @@ function compileInlineBindings( config, str ) {
|
|
|
235
235
|
let $itemNode__ = $existing__.get( $key___ );
|
|
236
236
|
if ( $itemNode__ ) {
|
|
237
237
|
$existing__.delete( $key___ );
|
|
238
|
-
$
|
|
238
|
+
$exec__wq($itemNode__, '${ config.BINDINGS_API.api.bind }', $itemBinding__ );
|
|
239
239
|
} else {
|
|
240
240
|
$itemNode__ = ( Array.isArray( $import__.value ) ? $import__.value[ 0 ] : ( $import__.value instanceof window.HTMLTemplateElement ? $import__.value.content.firstElementChild : $import__.value ) ).cloneNode( true );
|
|
241
241
|
$itemNode__.setAttribute( "${ config.attr.itemIndex }", $key___ );
|
|
242
|
-
$
|
|
243
|
-
$
|
|
242
|
+
$exec__wq($itemNode__, '${ config.BINDINGS_API.api.bind }', $itemBinding__ );
|
|
243
|
+
$exec__wq(this, 'appendChild', $itemNode__ );
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
if ( ${ kind === 'in' ? `!( ${ production[ 0 ] } in $iteratee__ )` : `typeof ${ production[ 0 ] } === 'undefined'` } ) { $itemNode__.remove(); }
|
|
@@ -262,7 +262,7 @@ function compileInlineBindings( config, str ) {
|
|
|
262
262
|
}
|
|
263
263
|
// Functions
|
|
264
264
|
if ( directive === '$' ) {
|
|
265
|
-
return `$
|
|
265
|
+
return `$exec__wq(this, '${ param }', ${ arg });`;
|
|
266
266
|
}
|
|
267
267
|
if ( str.trim() ) throw new Error( `Invalid binding: ${ str }.` );
|
|
268
268
|
} ).join( `\n` );
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @imports
|
|
4
4
|
*/
|
|
5
5
|
import { getDefs } from './index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { _wq, env } from '../util.js';
|
|
7
7
|
|
|
8
8
|
export default class HTMLModule {
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ export default class HTMLModule {
|
|
|
11
11
|
* @instance
|
|
12
12
|
*/
|
|
13
13
|
static instance( host ) {
|
|
14
|
-
return
|
|
14
|
+
return _wq( host ).get( 'defsmanager::instance' ) || new this( host );
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -19,8 +19,8 @@ export default class HTMLModule {
|
|
|
19
19
|
*/
|
|
20
20
|
constructor( host, parent = null, level = 0 ) {
|
|
21
21
|
const { window } = env, { webqit: { realdom, oohtml: { configs } } } = window;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
_wq( host ).get( `defsmanager::instance` )?.dispose();
|
|
23
|
+
_wq( host ).set( `defsmanager::instance`, this );
|
|
24
24
|
this.window = window;
|
|
25
25
|
this.host = host;
|
|
26
26
|
this.config = configs.HTML_IMPORTS;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @imports
|
|
4
4
|
*/
|
|
5
5
|
import HTMLImportsContext from './HTMLImportsContext.js';
|
|
6
|
-
import {
|
|
6
|
+
import { _wq, env } from '../util.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Creates the HTMLImportElement class.
|
|
@@ -27,7 +27,7 @@ export default function() {
|
|
|
27
27
|
*/
|
|
28
28
|
static instance( node ) {
|
|
29
29
|
if ( configs.HTML_IMPORTS.elements.import.includes( '-' ) && ( node instanceof this ) ) return node;
|
|
30
|
-
return
|
|
30
|
+
return _wq( node ).get( 'import::instance' ) || new this( node );
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
@@ -37,7 +37,7 @@ export default function() {
|
|
|
37
37
|
super();
|
|
38
38
|
// --------
|
|
39
39
|
const el = args[ 0 ] || this;
|
|
40
|
-
|
|
40
|
+
_wq( el ).set( 'import::instance', this );
|
|
41
41
|
Object.defineProperty( this, 'el', { get: () => el, configurable: false } );
|
|
42
42
|
|
|
43
43
|
const priv = {};
|
|
@@ -83,8 +83,8 @@ export default function() {
|
|
|
83
83
|
slottedElements.forEach( ( slottedElement, i ) => {
|
|
84
84
|
const tagName = slottedElement.tagName, fragmentDef = slottedElement.getAttribute( configs.HTML_IMPORTS.attr.fragmentdef ) || '';
|
|
85
85
|
const originalsMatch = ( i ++, identifiersMap.find( fragmentIdentifiers => fragmentIdentifiers.tagName === tagName && fragmentIdentifiers.fragmentDef === fragmentDef && fragmentIdentifiers.i === i ) );
|
|
86
|
-
if ( originalsMatch )
|
|
87
|
-
|
|
86
|
+
if ( originalsMatch ) _wq( slottedElement ).set( 'original@imports', originalsMatch.el ); // Or should we throw integrity error here?
|
|
87
|
+
_wq( slottedElement ).set( 'slot@imports', this.el );
|
|
88
88
|
priv.slottedElements.add( slottedElement );
|
|
89
89
|
} );
|
|
90
90
|
priv.originalsRemapped = true;
|
|
@@ -105,7 +105,7 @@ export default function() {
|
|
|
105
105
|
if ( !priv.slottedElements.size ) return restore();
|
|
106
106
|
const autoRestoreRealtime = realdom.realtime( priv.anchorNode.parentNode ).observe( [ ...priv.slottedElements ], record => {
|
|
107
107
|
record.exits.forEach( outgoingNode => {
|
|
108
|
-
|
|
108
|
+
_wq( outgoingNode ).delete( 'slot@imports' );
|
|
109
109
|
priv.slottedElements.delete( outgoingNode );
|
|
110
110
|
} );
|
|
111
111
|
if ( !priv.slottedElements.size ) {
|
|
@@ -139,7 +139,7 @@ export default function() {
|
|
|
139
139
|
const escapeElement = window.document.createElement( 'div' );
|
|
140
140
|
escapeElement.textContent = this.el.outerHTML;
|
|
141
141
|
const anchorNode = window.document.createComment( escapeElement.innerHTML );
|
|
142
|
-
|
|
142
|
+
_wq( anchorNode ).set( 'isAnchorNode', true );
|
|
143
143
|
return anchorNode;
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -160,7 +160,7 @@ export default function() {
|
|
|
160
160
|
this.el.setAttribute( 'data-nodecount', slottableElements.size );
|
|
161
161
|
this[ '#' ].autoRestore( () => {
|
|
162
162
|
this[ '#' ].slottedElements.forEach( slottedElement => {
|
|
163
|
-
const slottedElementOriginal =
|
|
163
|
+
const slottedElementOriginal = _wq( slottedElement ).get( 'original@imports' );
|
|
164
164
|
// If still available in source, simply leave unchanged
|
|
165
165
|
// otherwise remove it from slot... to reflect this change
|
|
166
166
|
if ( slottableElements.has( slottedElementOriginal ) ) {
|
|
@@ -187,8 +187,8 @@ export default function() {
|
|
|
187
187
|
if ( !slottableElementClone.hasAttribute( configs.HTML_IMPORTS.attr.fragmentdef ) ) {
|
|
188
188
|
slottableElementClone.toggleAttribute( configs.HTML_IMPORTS.attr.fragmentdef, true );
|
|
189
189
|
}
|
|
190
|
-
|
|
191
|
-
|
|
190
|
+
_wq( slottableElementClone ).set( 'original@imports', slottableElement );
|
|
191
|
+
_wq( slottableElementClone ).set( 'slot@imports', this.el );
|
|
192
192
|
this[ '#' ].slottedElements.add( slottableElementClone );
|
|
193
193
|
this[ '#' ].anchorNode.before( slottableElementClone );
|
|
194
194
|
} );
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import HTMLModule from './HTMLModule.js';
|
|
6
6
|
import HTMLImportsContext from './HTMLImportsContext.js';
|
|
7
7
|
import _HTMLImportElement from './_HTMLImportElement.js';
|
|
8
|
-
import {
|
|
8
|
+
import { _wq, _init } from '../util.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Initializes HTML Modules.
|
|
@@ -45,11 +45,11 @@ export default function init($config = {}) {
|
|
|
45
45
|
* @return Object
|
|
46
46
|
*/
|
|
47
47
|
export function getDefs(node, autoCreate = true) {
|
|
48
|
-
if (!
|
|
48
|
+
if (!_wq(node).has('defs') && autoCreate) {
|
|
49
49
|
const defs = Object.create(null);
|
|
50
|
-
|
|
50
|
+
_wq(node).set('defs', defs);
|
|
51
51
|
}
|
|
52
|
-
return
|
|
52
|
+
return _wq(node).get('defs');
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
@@ -180,7 +180,7 @@ function realtime(config) {
|
|
|
180
180
|
if (window.webqit.env === 'server') return;
|
|
181
181
|
realdom.realtime(window.document).query(`(${config.anchorNodeSelector})`, record => {
|
|
182
182
|
record.entrants.forEach(anchorNode => {
|
|
183
|
-
if (
|
|
183
|
+
if (_wq(anchorNode).get('isAnchorNode')) return; // Doubling up on the early return above! Ignoring every just created anchorNode
|
|
184
184
|
const reviver = window.document.createElement('div');
|
|
185
185
|
reviver.innerHTML = anchorNode.nodeValue;
|
|
186
186
|
reviver.innerHTML = reviver.firstChild.textContent;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @imports
|
|
4
4
|
*/
|
|
5
5
|
import DOMNamingContext from './DOMNamingContext.js';
|
|
6
|
-
import {
|
|
6
|
+
import { _wq, _init, _splitOuter, _fromHash, _toHash, getInternalAttrInteraction, internalAttrInteraction } from '../util.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @init
|
|
@@ -119,15 +119,15 @@ export function rewriteSelector( selectorText, namespaceUUID, scopeSelector = nu
|
|
|
119
119
|
*/
|
|
120
120
|
export function getOwnNamespaceObject( node ) {
|
|
121
121
|
const window = this;
|
|
122
|
-
if ( !
|
|
122
|
+
if ( !_wq( node ).has( 'namespace' ) ) {
|
|
123
123
|
const namespaceObj = Object.create( null );
|
|
124
|
-
|
|
124
|
+
_wq( node ).set( 'namespace', namespaceObj );
|
|
125
125
|
const isDocumentRoot = [ window.Document, window.ShadowRoot ].some( x => node instanceof x );
|
|
126
126
|
Object.defineProperty( namespaceObj, Symbol.toStringTag, { get() {
|
|
127
127
|
return isDocumentRoot ? 'RootNamespaceRegistry' : 'NamespaceRegistry';
|
|
128
128
|
} } );
|
|
129
129
|
}
|
|
130
|
-
return
|
|
130
|
+
return _wq( node ).get( 'namespace' );
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/**
|
|
@@ -194,8 +194,8 @@ function realtime( config ) {
|
|
|
194
194
|
const relMap = { id: 'id'/* just in case it's in attrList */, for: 'htmlFor', 'aria-owns': 'ariaOwns', 'aria-controls': 'ariaControls', 'aria-labelledby': 'ariaLabelledBy', 'aria-describedby': 'ariaDescribedBy', 'aria-flowto': 'ariaFlowto', 'aria-activedescendant': 'ariaActiveDescendant', 'aria-details': 'ariaDetails', 'aria-errormessage': 'ariaErrorMessage' };
|
|
195
195
|
const $lidUtil = lidUtil( config );
|
|
196
196
|
const uuidsToLidrefs = ( node, attrName, getter ) => {
|
|
197
|
-
if ( !getInternalAttrInteraction( node, attrName ) &&
|
|
198
|
-
return
|
|
197
|
+
if ( !getInternalAttrInteraction( node, attrName ) && _wq( node, 'attrOriginals' ).has( attrName ) ) {
|
|
198
|
+
return _wq( node, 'attrOriginals' ).get( attrName );
|
|
199
199
|
}
|
|
200
200
|
const value = getter();
|
|
201
201
|
if ( getInternalAttrInteraction( node, attrName ) ) return value;
|
|
@@ -220,7 +220,7 @@ function realtime( config ) {
|
|
|
220
220
|
const getAttributeDescr = Object.getOwnPropertyDescriptor( window.Element.prototype, 'getAttribute' );
|
|
221
221
|
Object.defineProperty( window.Element.prototype, 'getAttribute', { ...getAttributeDescr, value( attrName ) {
|
|
222
222
|
const getter = () => getAttributeDescr.value.call( this, attrName );
|
|
223
|
-
return attrList.includes( attrName ) && !
|
|
223
|
+
return attrList.includes( attrName ) && !_wq( this, 'lock' ).get( attrName ) ? uuidsToLidrefs( this, attrName, getter ) : getter();
|
|
224
224
|
} } );
|
|
225
225
|
// Hide implementation details on the Attr node too.
|
|
226
226
|
const propertyDescr = Object.getOwnPropertyDescriptor( window.Attr.prototype, 'value' );
|
|
@@ -277,11 +277,11 @@ function realtime( config ) {
|
|
|
277
277
|
Observer.set( namespaceObj, id, entry );
|
|
278
278
|
}
|
|
279
279
|
} else {
|
|
280
|
-
|
|
280
|
+
_wq( entry, 'attrOriginals' ).set( attrName, value ); // Save original before rewrite
|
|
281
281
|
const newAttrValue = value.split( ' ' ).map( idref => ( idref = idref.trim() ) && $lidUtil.isUuid( idref ) ? idref : $lidUtil.toUuid( namespaceUUID, idref ) ).join( ' ' );
|
|
282
282
|
entry.setAttribute( attrName, newAttrValue );
|
|
283
|
-
|
|
284
|
-
|
|
283
|
+
_wq( namespaceObj ).set( 'idrefs', _wq( namespaceObj ).get( 'idrefs' ) || new Set );
|
|
284
|
+
_wq( namespaceObj ).get( 'idrefs' ).add( entry );
|
|
285
285
|
}
|
|
286
286
|
} );
|
|
287
287
|
};
|
|
@@ -295,9 +295,9 @@ function realtime( config ) {
|
|
|
295
295
|
Observer.deleteProperty( namespaceObj, id );
|
|
296
296
|
}
|
|
297
297
|
} else {
|
|
298
|
-
const newAttrValue =
|
|
298
|
+
const newAttrValue = _wq( entry, 'attrOriginals' ).get( attrName );// oldValue.split( ' ' ).map( lid => ( lid = lid.trim() ) && $lidUtil.uuidToLidref( lid ) ).join( ' ' );
|
|
299
299
|
if ( entry.hasAttribute( attrName ) ) entry.setAttribute( attrName, newAttrValue );
|
|
300
|
-
|
|
300
|
+
_wq( namespaceObj ).get( 'idrefs' )?.delete( entry );
|
|
301
301
|
}
|
|
302
302
|
} );
|
|
303
303
|
};
|
|
@@ -310,13 +310,13 @@ function realtime( config ) {
|
|
|
310
310
|
if ( !entry.hasAttribute( attrName ) ) return;
|
|
311
311
|
const attrValue = () => entry.getAttribute( attrName );
|
|
312
312
|
cleanupBinding( entry, attrName, attrValue/* Current resolved value as-is */, oldNamespaceObj );
|
|
313
|
-
if ( entry.isConnected ) { setupBinding( entry, attrName,
|
|
313
|
+
if ( entry.isConnected ) { setupBinding( entry, attrName, _wq( entry, 'attrOriginals' ).get( attrName )/* Saved original value */ || attrValue/* Lest it's ID */, newNamespaceObj ); }
|
|
314
314
|
};
|
|
315
315
|
record.exits.forEach( entry => {
|
|
316
316
|
if ( entry.isConnected ) {
|
|
317
317
|
const namespaceObj = getOwnNamespaceObject.call( window, entry );
|
|
318
318
|
// Detach ID and IDREF associations
|
|
319
|
-
for ( const node of new Set( [ ...Object.values( namespaceObj ), ...(
|
|
319
|
+
for ( const node of new Set( [ ...Object.values( namespaceObj ), ...( _wq( namespaceObj ).get( 'idrefs' ) || [] ) ] ) ) {
|
|
320
320
|
for ( const attrName of attrList ) { reAssociate( node, attrName, namespaceObj ); }
|
|
321
321
|
}
|
|
322
322
|
}
|
|
@@ -330,7 +330,7 @@ function realtime( config ) {
|
|
|
330
330
|
// Claim ID and IDREF associations
|
|
331
331
|
let newSuperNamespaceObj;
|
|
332
332
|
const superNamespaceObj = getOwnerNamespaceObject.call( window, entry, true );
|
|
333
|
-
for ( const node of new Set( [ ...Object.values( superNamespaceObj ), ...(
|
|
333
|
+
for ( const node of new Set( [ ...Object.values( superNamespaceObj ), ...( _wq( superNamespaceObj ).get( 'idrefs' ) || [] ) ] ) ) {
|
|
334
334
|
if ( ( newSuperNamespaceObj = getOwnerNamespaceObject.call( window, node, true ) ) === superNamespaceObj ) continue;
|
|
335
335
|
for ( const attrName of attrList ) { reAssociate( node, attrName, superNamespaceObj, newSuperNamespaceObj ); }
|
|
336
336
|
}
|
package/src/scoped-js/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @imports
|
|
4
4
|
*/
|
|
5
5
|
import { resolveParams } from '@webqit/quantum-js/params';
|
|
6
|
-
import {
|
|
6
|
+
import { _wq, _init, _toHash, _fromHash } from '../util.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @init
|
|
@@ -72,10 +72,10 @@ async function execute( config, execHash ) {
|
|
|
72
72
|
}
|
|
73
73
|
// Execute and save state
|
|
74
74
|
const varScope = script.scoped ? thisContext : script.getRootNode();
|
|
75
|
-
if ( !
|
|
76
|
-
|
|
75
|
+
if ( !_wq( varScope ).has( 'scriptEnv' ) ) {
|
|
76
|
+
_wq( varScope ).set( 'scriptEnv', Object.create( null ) );
|
|
77
77
|
}
|
|
78
|
-
const state = await ( await compiledScript.bind( thisContext,
|
|
78
|
+
const state = await ( await compiledScript.bind( thisContext, _wq( 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(); }
|
package/src/util.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* @imports
|
|
4
4
|
*/
|
|
5
5
|
import realdomInit from '@webqit/realdom';
|
|
6
|
-
import {
|
|
6
|
+
import { _wq as __wq } from '@webqit/util/js/index.js';
|
|
7
7
|
import { _merge } from '@webqit/util/obj/index.js';
|
|
8
8
|
import { _toTitle } from '@webqit/util/str/index.js';
|
|
9
9
|
|
|
10
|
-
export const
|
|
10
|
+
export const _wq = ( target, ...args ) => __wq( target, 'oohtml', ...args );
|
|
11
11
|
|
|
12
12
|
export const env = {};
|
|
13
13
|
|
|
@@ -43,13 +43,13 @@ export function _init( name, $config, $defaults ) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export function getInternalAttrInteraction( node, attrName ) {
|
|
46
|
-
return
|
|
46
|
+
return _wq( node, 'internalAttrInteractions' ).get( attrName );
|
|
47
47
|
}
|
|
48
48
|
export function internalAttrInteraction( node, attrName, callback ) {
|
|
49
|
-
const savedAttrLocking =
|
|
50
|
-
|
|
49
|
+
const savedAttrLocking = _wq( node, 'internalAttrInteractions' ).get( attrName );
|
|
50
|
+
_wq( node, 'internalAttrInteractions' ).set( attrName, true );
|
|
51
51
|
const value = callback();
|
|
52
|
-
|
|
52
|
+
_wq( node, 'internalAttrInteractions' ).set( attrName, savedAttrLocking );
|
|
53
53
|
return value;
|
|
54
54
|
}
|
|
55
55
|
|