@webqit/oohtml 3.1.7 → 3.1.8
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 +21 -21
- package/dist/bindings-api.js +1 -1
- package/dist/bindings-api.js.map +2 -2
- package/dist/context-api.js +1 -1
- package/dist/context-api.js.map +2 -2
- package/dist/data-binding.js +5 -4
- package/dist/data-binding.js.map +2 -2
- package/dist/html-imports.js +1 -1
- package/dist/html-imports.js.map +2 -2
- package/dist/main.js +14 -13
- package/dist/main.js.map +2 -2
- package/dist/main.lite.js +14 -13
- package/dist/main.lite.js.map +2 -2
- package/dist/namespaced-html.js +1 -1
- package/dist/namespaced-html.js.map +2 -2
- package/dist/scoped-css.js +1 -1
- package/dist/scoped-css.js.map +2 -2
- package/dist/scoped-js.js +1 -1
- package/dist/scoped-js.js.map +2 -2
- package/package.json +3 -3
- package/src/context-api/DOMContext.js +1 -1
- package/src/data-binding/index.js +23 -16
|
@@ -50,9 +50,15 @@ function realtime( config ) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
function createDynamicScope( config, root ) {
|
|
53
|
-
const { webqit: { Observer, DOMBindingsContext } } = this;
|
|
53
|
+
const { webqit: { realdom, Observer, DOMBindingsContext } } = this;
|
|
54
54
|
if ( _( root ).has( 'data-binding' ) ) return _( root ).get( 'data-binding' );
|
|
55
55
|
const scope = Object.create( null ), abortController = new AbortController;
|
|
56
|
+
scope[ '$exec__' ] = ( target, prop, ...args ) => {
|
|
57
|
+
realdom.schedule( 'write', () => target[ prop ]( ...args ) );
|
|
58
|
+
};
|
|
59
|
+
scope[ '$assign__' ] = ( target, prop, val ) => {
|
|
60
|
+
realdom.schedule( 'write', () => (target[ prop ] = val) );
|
|
61
|
+
};
|
|
56
62
|
Observer.intercept( scope, {
|
|
57
63
|
get: ( e, recieved, next ) => {
|
|
58
64
|
if ( !( e.key in scope ) ) {
|
|
@@ -130,10 +136,10 @@ const discreteParseCache = new Map;
|
|
|
130
136
|
function compileDiscreteBindings( config, str ) {
|
|
131
137
|
if ( discreteParseCache.has( str ) ) return discreteParseCache.get( str );
|
|
132
138
|
let source = `let content = ((${ str }) ?? '') + '';`;
|
|
133
|
-
source +=
|
|
134
|
-
source += `if ( this.$oohtml_internal_databinding_anchorNode ) { this.$oohtml_internal_databinding_anchorNode
|
|
135
|
-
const { webqit: {
|
|
136
|
-
const compiled = new
|
|
139
|
+
source += `$assign__(this, 'nodeValue', content);`;
|
|
140
|
+
source += `if ( this.$oohtml_internal_databinding_anchorNode ) { $assign__(this.$oohtml_internal_databinding_anchorNode, 'nodeValue', "${ config.tokens.tagStart }${ escDouble( str ) }${ config.tokens.stateStart }" + content.length + "${ config.tokens.stateEnd } ${ config.tokens.tagEnd }"); }`;
|
|
141
|
+
const { webqit: { QuantumModule } } = this;
|
|
142
|
+
const compiled = new QuantumModule( source );
|
|
137
143
|
discreteParseCache.set( str, compiled );
|
|
138
144
|
return compiled;
|
|
139
145
|
}
|
|
@@ -157,19 +163,19 @@ function compileInlineBindings( config, str ) {
|
|
|
157
163
|
const directive = left[ 0 ], param = left.slice( 1 ).trim();
|
|
158
164
|
const arg = `(${ right })`, $arg = `(${ arg } ?? '')`;
|
|
159
165
|
if ( directive === '&' ) {
|
|
160
|
-
if ( param.startsWith( '--' ) ) return
|
|
161
|
-
return
|
|
166
|
+
if ( param.startsWith( '--' ) ) return `$exec__(this.style, 'setProperty', "${ escDouble( param ) }", ${ $arg });`;
|
|
167
|
+
return `$assign__(this.style, "${ escDouble( param ) }", ${ $arg });`;
|
|
162
168
|
}
|
|
163
|
-
if ( directive === '%' ) return
|
|
169
|
+
if ( directive === '%' ) return `$exec__(this.classList, 'toggle', "${ escDouble( param ) }", !!${ arg });`;
|
|
164
170
|
if ( directive === '~' ) {
|
|
165
|
-
if ( param.startsWith( '?' ) ) return
|
|
166
|
-
return
|
|
171
|
+
if ( param.startsWith( '?' ) ) return `$exec__(this, 'toggleAttribute', "${ escDouble( param.substring( 1 ).trim() ) }", !!${ arg });`;
|
|
172
|
+
return `$exec__(this, 'setAttribute', "${ escDouble( param ) }", ${ $arg });`;
|
|
167
173
|
}
|
|
168
174
|
if ( directive === '@' ) {
|
|
169
175
|
if ( validation[ param ] ) throw new Error( `Duplicate binding: ${ left }.` );
|
|
170
176
|
validation[ param ] = true;
|
|
171
|
-
if ( param === 'text' ) return
|
|
172
|
-
if ( param === 'html' ) return
|
|
177
|
+
if ( param === 'text' ) return `$assign__(this, 'textContent', ${ $arg });`;
|
|
178
|
+
if ( param === 'html' ) return `$exec__(this, 'setHTML', ${ $arg });`;
|
|
173
179
|
if ( param === 'items' ) {
|
|
174
180
|
const [ iterationSpec, importSpec ] = splitOuter( right, '/' );
|
|
175
181
|
if ( !importSpec ) throw new Error( `Invalid ${ directive }items spec: ${ str }; no import specifier.` );
|
|
@@ -200,13 +206,14 @@ function compileInlineBindings( config, str ) {
|
|
|
200
206
|
let $itemNode__ = $existing__.get( $key___ );
|
|
201
207
|
if ( $itemNode__ ) {
|
|
202
208
|
$existing__.delete( $key___ );
|
|
209
|
+
$exec__($itemNode__, '${ config.BINDINGS_API.api.bind }', $itemBinding__ );
|
|
203
210
|
} else {
|
|
204
211
|
$itemNode__ = ( Array.isArray( $import__.value ) ? $import__.value[ 0 ] : ( $import__.value instanceof window.HTMLTemplateElement ? $import__.value.content.firstElementChild : $import__.value ) ).cloneNode( true );
|
|
205
212
|
$itemNode__.setAttribute( "${ config.attr.itemIndex }", $key___ );
|
|
206
|
-
|
|
213
|
+
$exec__($itemNode__, '${ config.BINDINGS_API.api.bind }', $itemBinding__ );
|
|
214
|
+
$exec__(this, 'appendChild', $itemNode__ );
|
|
207
215
|
}
|
|
208
216
|
|
|
209
|
-
$itemNode__.${ config.BINDINGS_API.api.bind }( $itemBinding__ );
|
|
210
217
|
if ( ${ kind === 'in' ? `!( ${ production[ 0 ] } in $iteratee__ )` : `typeof ${ production[ 0 ] } === 'undefined'` } ) { $itemNode__.remove(); }
|
|
211
218
|
}
|
|
212
219
|
$existing__.forEach( x => x.remove() );
|
|
@@ -216,8 +223,8 @@ function compileInlineBindings( config, str ) {
|
|
|
216
223
|
}
|
|
217
224
|
if ( str.trim() ) throw new Error( `Invalid binding: ${ str }.` );
|
|
218
225
|
} ).join( `\n` );
|
|
219
|
-
const { webqit: {
|
|
220
|
-
const compiled = new
|
|
226
|
+
const { webqit: { QuantumModule } } = this;
|
|
227
|
+
const compiled = new QuantumModule( source );
|
|
221
228
|
inlineParseCache.set( str, compiled );
|
|
222
229
|
return compiled;
|
|
223
230
|
}
|