@makano/rew 1.2.59 → 1.2.62
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/rew/pkgs/web.js +11 -3
- package/package.json +1 -1
- package/runtime.d.ts +1 -1
package/lib/rew/pkgs/web.js
CHANGED
@@ -304,6 +304,14 @@ class Page extends Node {
|
|
304
304
|
el.style.setProperty(i, value[i]);
|
305
305
|
}
|
306
306
|
return;
|
307
|
+
} else if(key.startsWith('on')){
|
308
|
+
if(!el.listeners) el.listeners = [];
|
309
|
+
if(el.listeners.includes(value)) return;
|
310
|
+
el.listeners.push(value);
|
311
|
+
el.addEventListener(key.replace('on', '').toLowerCase(), (event) => {
|
312
|
+
new Function('event', value).call(event.target, event);
|
313
|
+
});
|
314
|
+
return;
|
307
315
|
}
|
308
316
|
el.setAttribute(key, defVal);
|
309
317
|
}
|
@@ -443,9 +451,9 @@ module.exports = (context, importOptions) => {
|
|
443
451
|
state(value) {
|
444
452
|
return new State(value);
|
445
453
|
}
|
446
|
-
|
447
|
-
const statesMapped = states.map(i => `getState('${i.id}')`);
|
448
|
-
return `((${callback})(...[${statesMapped}]))`;
|
454
|
+
invokeState(states, callback){
|
455
|
+
const statesMapped = states.map(i => i instanceof State ? `getState('${i.id}')` : (typeof i == "function" ? i.toString() : JSON.stringify(i)));
|
456
|
+
return `((${callback})(event, ...[${statesMapped}]))`;
|
449
457
|
}
|
450
458
|
async bundle(filepath, options = {}) {
|
451
459
|
const virtualModuleId = `virtual:${filepath}`;
|
package/package.json
CHANGED
package/runtime.d.ts
CHANGED
@@ -492,7 +492,7 @@ declare class ModuleWeb {
|
|
492
492
|
|
493
493
|
state(value): ModuleWebState | any;
|
494
494
|
// @ts-ignore
|
495
|
-
|
495
|
+
invokeState(states: State[], callback: CallableFunction): any;
|
496
496
|
|
497
497
|
bundle(filePath: string, options?: Record<string, any>): string;
|
498
498
|
}
|