@webqit/oohtml 4.1.15 → 4.3.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 +2 -2
- package/dist/context-api.js +1 -1
- package/dist/context-api.js.map +2 -2
- package/dist/data-binding.js +4 -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 +4 -4
- package/dist/main.js.map +2 -2
- package/dist/main.lite.js +7 -7
- 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 +2 -2
- package/src/data-binding/index.js +15 -6
- package/src/namespaced-html/index.js +1 -1
- package/src/scoped-js/index.js +1 -1
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.3.0",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@webqit/quantum-js": "^4.5.11",
|
|
43
|
-
"@webqit/realdom": "^2.1.
|
|
43
|
+
"@webqit/realdom": "^2.1.30",
|
|
44
44
|
"@webqit/util": "^0.8.11"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
@@ -54,8 +54,7 @@ function createDynamicScope( config, root ) {
|
|
|
54
54
|
const scope = Object.create( null ), abortController = new AbortController;
|
|
55
55
|
scope[ '$exec__' ] = ( target, prop, ...args ) => {
|
|
56
56
|
const exec = () => {
|
|
57
|
-
try { target[ prop ]( ...args ); }
|
|
58
|
-
catch( e ) { console.error( `${ e.message } at ${ e.cause }` ); }
|
|
57
|
+
try { target[ prop ]( ...args ); } catch( e ) { console.error( `Error executing "${ prop }": ${ e.message } at ${ e.cause }` ); }
|
|
59
58
|
};
|
|
60
59
|
realdom.schedule( 'write', exec );
|
|
61
60
|
};
|
|
@@ -177,20 +176,24 @@ function compileInlineBindings( config, str ) {
|
|
|
177
176
|
const [ left, right ] = _splitOuter( str, ':' ).map( x => x.trim() );
|
|
178
177
|
const directive = left[ 0 ], param = left.slice( 1 ).trim();
|
|
179
178
|
const arg = `(${ right })`, $arg = `(${ arg } ?? '')`;
|
|
179
|
+
// CSS
|
|
180
180
|
if ( directive === '&' ) {
|
|
181
181
|
if ( param.startsWith( '--' ) ) return `$exec__(this.style, 'setProperty', "${ escDouble( param ) }", ${ $arg });`;
|
|
182
182
|
return `$assign__(this.style, "${ escDouble( param ) }", ${ $arg });`;
|
|
183
183
|
}
|
|
184
|
+
// Class list
|
|
184
185
|
if ( directive === '%' ) return `$exec__(this.classList, 'toggle', "${ escDouble( param ) }", !!${ arg });`;
|
|
186
|
+
// Attribute
|
|
185
187
|
if ( directive === '~' ) {
|
|
186
188
|
if ( param.startsWith( '?' ) ) return `$exec__(this, 'toggleAttribute', "${ escDouble( param.substring( 1 ).trim() ) }", !!${ arg });`;
|
|
187
189
|
return `$exec__(this, 'setAttribute', "${ escDouble( param ) }", ${ $arg });`;
|
|
188
190
|
}
|
|
189
|
-
|
|
191
|
+
// Structure
|
|
192
|
+
if ( directive === '#' ) {
|
|
190
193
|
if ( validation[ param ] ) throw new Error( `Duplicate binding: ${ left }.` );
|
|
191
194
|
validation[ param ] = true;
|
|
192
195
|
if ( param === 'text' ) return `$assign__(this, 'textContent', ${ $arg });`;
|
|
193
|
-
if ( param === 'html' ) return `$exec__(this, '
|
|
196
|
+
if ( param === 'html' ) return `$exec__(this, 'setHTMLUnsafe', ${ $arg });`;
|
|
194
197
|
if ( param === 'items' ) {
|
|
195
198
|
const [ iterationSpec, importSpec ] = _splitOuter( right, '/' );
|
|
196
199
|
if ( !importSpec ) throw new Error( `Invalid ${ directive }items spec: ${ str }; no import specifier.` );
|
|
@@ -235,14 +238,20 @@ function compileInlineBindings( config, str ) {
|
|
|
235
238
|
$existing__.clear();
|
|
236
239
|
}`;
|
|
237
240
|
}
|
|
238
|
-
|
|
241
|
+
}
|
|
242
|
+
// Events
|
|
243
|
+
if ( directive === '@' ) {
|
|
239
244
|
return `
|
|
240
|
-
const handler =
|
|
245
|
+
const handler = event => ${ right.startsWith('{') ? right : arg };
|
|
241
246
|
this.addEventListener( '${ param }', handler );
|
|
242
247
|
const abort = () => this.removeEventListener( '${ param }', handler );
|
|
243
248
|
this.$oohtml_internal_databinding_signals?.push( { abort } );
|
|
244
249
|
`;
|
|
245
250
|
}
|
|
251
|
+
// Functions
|
|
252
|
+
if ( directive === '$' ) {
|
|
253
|
+
return `$exec__(this, '${ param }', ${ arg });`;
|
|
254
|
+
}
|
|
246
255
|
if ( str.trim() ) throw new Error( `Invalid binding: ${ str }.` );
|
|
247
256
|
} ).join( `\n` );
|
|
248
257
|
const { webqit: { QuantumModule } } = this;
|
|
@@ -297,7 +297,7 @@ function realtime( config ) {
|
|
|
297
297
|
} else {
|
|
298
298
|
const newAttrValue = _( entry, 'attrOriginals' ).get( attrName );// oldValue.split( ' ' ).map( lid => ( lid = lid.trim() ) && $lidUtil.uuidToLidref( lid ) ).join( ' ' );
|
|
299
299
|
entry.setAttribute( attrName, newAttrValue );
|
|
300
|
-
_( namespaceObj ).get( 'idrefs' )
|
|
300
|
+
_( namespaceObj ).get( 'idrefs' )?.delete( entry );
|
|
301
301
|
}
|
|
302
302
|
} );
|
|
303
303
|
};
|
package/src/scoped-js/index.js
CHANGED
|
@@ -75,7 +75,7 @@ async function execute( config, execHash ) {
|
|
|
75
75
|
if ( !_( varScope ).has( 'scriptEnv' ) ) {
|
|
76
76
|
_( varScope ).set( 'scriptEnv', Object.create( null ) );
|
|
77
77
|
}
|
|
78
|
-
const state = ( await compiledScript.bind( thisContext, _( varScope ).get( 'scriptEnv' ) ) ).execute();
|
|
78
|
+
const state = await ( 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(); }
|