pawajs 2.0.2 → 2.0.4

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/CHANGELOG.md CHANGED
@@ -19,4 +19,6 @@ CHANGELOG.md
19
19
  + version 1.4.33 - added registerComponent.lazy
20
20
  + version 1.4.33 -1.4.42 fixing lazy registration component
21
21
  + version 1.5.1 stable
22
- + version 1.5.2 - added function dependencies
22
+ + version 1.5.2 - added function dependencies
23
+ + version 2.0.1 -2.0.2 made runEffect to be global or component capability
24
+ + version 2.0.3 integrating HMR system
package/README.md CHANGED
@@ -35,15 +35,53 @@ npm install pawajs
35
35
  CDN
36
36
 
37
37
  ```html
38
- <head>
39
- </head>
40
- <body>
41
- <div id="app"></div>
42
- <script type="module" src="https://cdn.jsdelivr.net/npm/pawajs@latestVersion/index.js"></script>
43
- <script type="module">
44
- window.$pawa.pawaStartApp(document.getElementById('app'));
45
- </script>
46
- </body>
38
+ <!doctype html>
39
+ <html lang="en">
40
+ <head>
41
+ <meta charset="UTF-8" />
42
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
43
+ <title>PawaJS CDN Demo</title>
44
+ </head>
45
+ <body>
46
+ <div id="app">
47
+ <counter></counter>
48
+ </div>
49
+
50
+ <!-- PawaJS CDN -->
51
+ <script type="module" src="https://cdn.jsdelivr.net/npm/pawajs-cdn@latest/dist/pawajs.iife.min.js"></script>
52
+
53
+ <script type="module">
54
+ const { pawaStartApp, $state, RegisterComponent, useInsert, html } = Pawa;
55
+
56
+ // 1. Define the component
57
+ const Counter = () => {
58
+ const count = $state(0);
59
+ useInsert({ count });
60
+
61
+ return html`
62
+ <div class="p-8 border rounded-lg shadow-md flex flex-col items-center">
63
+ <h1 class="text-2xl font-bold">Count: @{count.value}</h1>
64
+ <button
65
+ on-click="count.value++"
66
+ class="mt-4 px-6 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors"
67
+ >
68
+ Increment
69
+ </button>
70
+ </div>
71
+ `;
72
+ };
73
+
74
+ // 2. Register it as a custom element
75
+ RegisterComponent(Counter);
76
+
77
+ // 3. Start the app
78
+ document.addEventListener('DOMContentLoaded', () => {
79
+ const app = document.getElementById('app');
80
+ pawaStartApp(app);
81
+ });
82
+ </script>
83
+ </body>
84
+ </html>
47
85
  ```
48
86
 
49
87
  OR
@@ -202,7 +240,7 @@ PawaJS uses a simple `@{...}` syntax to embed dynamic JavaScript expressions dir
202
240
 
203
241
  <!-- Bind to attributes -->
204
242
  <div class="user-card @{user.value.isActive ? 'active' : 'inactive'}">
205
- <input value="@{user.value.name}" on-input="user.value.name = e.target.value">
243
+ <input @value="@{user.value.name}" on-input="user.value.name = e.target.value">
206
244
  </div>
207
245
  ```
208
246
 
@@ -304,7 +342,7 @@ const message = $state('This is a message from the parent!');
304
342
  useInsert({ message });
305
343
 
306
344
  return html`
307
- <todo-list :title="'My Todo List'" :message="message.value" class="to the rest prop">Children in here</todo-list>
345
+ <todo-list title="My Todo List" :message="message.value" class="to the rest prop">Children in here</todo-list>
308
346
  `;
309
347
  ```
310
348
 
package/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export interface PawaElement extends HTMLElement {
10
10
  _terminateEffects: Set<Function>;
11
11
  _deleteEffects: () => void;
12
12
  _slots: DocumentFragment;
13
- _stateContext: any;
13
+ _stateContext: StateContextType;
14
14
  _mainAttribute: Record<string, any>;
15
15
  _preRenderAvoid: string[];
16
16
  _lazy: boolean;
@@ -118,6 +118,31 @@ export interface PawaDev {
118
118
  logEffect(e: any, t: any): void;
119
119
  logComponent(n: any, t: any): void;
120
120
  }
121
+ type StateContextType={
122
+ _name:string,
123
+ _props:object,
124
+ _formerStateContext:stateContextType,
125
+ _elementContext:object,
126
+ _template:string,
127
+ _reactiveProps:object,
128
+ _restProps:object,
129
+ _hasRun:boolean,
130
+ _transportContext:object,
131
+ _static:any[],
132
+ _serializedData:object,
133
+ _formerContext:stateContextType,
134
+ _resume:boolean,
135
+ _suspense:string,
136
+ _hmr:boolean,
137
+ _hook:{
138
+ beforeMount:Function[],
139
+ reactiveEffect:Function[],
140
+ effect:Function[],
141
+ isMount:Function[],
142
+ isUnMount:Function[]
143
+ }
144
+ }
145
+ export const statecontext:StateContextType
121
146
 
122
147
  declare global {
123
148
  var __pawaDev: PawaDev;
@@ -265,11 +290,10 @@ export function RegisterComponent(...args: (string | Function)[]): void;
265
290
  export namespace RegisterComponent {
266
291
  /**
267
292
  * Registers components lazily. The component's bundle is only fetched during runime encounter.
268
- * (nam,import) or ([names,...],import)
293
+ * (name,import) or ([names,...],import)
269
294
  */
270
- export function lazy(...args: (string | Array<string> | Function)[]): Promise<void>;
295
+ export function lazy(...arg:Array<string|Function|Array<string>>): Promise<void>;
271
296
  }
272
-
273
297
  /**
274
298
  * Runs a side effect or lifecycle hook.
275
299
  * @param {(comment:PawaComment) => void | (() => void)} callback - Effect function,comment for component hacking and optionally returning cleanup .
@@ -360,7 +384,7 @@ export function forwardProps(props?: Record<string, any>): void;
360
384
  export function useInsert(obj?: Record<string, any>): void;
361
385
 
362
386
  export function setStateContext(context: any): any;
363
-
387
+ export function globalRerender(el:HTMLElement | string,formercontext)
364
388
  /**
365
389
  * Creates a reactive state.
366
390
  * @template T
package/index.js CHANGED
@@ -890,6 +890,17 @@ export const restoreContext = (state_context) => {
890
890
  }
891
891
  export const HmrComponentMap=new Map()
892
892
  const renderedComponentsRusumed=new Set()
893
+ export const globalRerender=(el,formercontext)=>{
894
+ if(!window?.hmr)return
895
+ let element
896
+ if (typeof el === 'string') {
897
+ const dom =document.createDocumentFragment()
898
+ dom.innerHTML=el
899
+ element=dom.firstElementChild
900
+ }else element=el
901
+ formerStateContext=formercontext
902
+ normal_component(element,formercontext,setStateContext,mapsPlugins,formercontext,pawaContext,stateWatch)
903
+ }
893
904
  /**
894
905
  *
895
906
  * @param {PawaElement|HTMLElement} el
@@ -903,7 +914,7 @@ const component = (el, resume = false, attr, notRender, stopResume) => {
903
914
 
904
915
  if (!resume) {
905
916
  if (el._lazy) {
906
- // pas the normal component to lazy handler
917
+ // passes the normal component to lazy handler
907
918
  el.style.opacity=0
908
919
  addLazyComponentElement(el,()=>normal_component(el, stateContext, setStateContext, mapsPlugins, formerStateContext, pawaContext, stateWatch))
909
920
  return
@@ -1205,9 +1216,11 @@ export const render = (el, contexts = {}, notRender, isName) => {
1205
1216
  startsWithSet.forEach(starts => {
1206
1217
 
1207
1218
  el._attributes.forEach(attr => {
1208
- if (attr.name.startsWith(starts)) {
1219
+ let attrName=attr.name.replace(/^-+/, '');
1220
+ attrName=attrName.trim()
1221
+ if (attrName.startsWith(starts)) {
1209
1222
  startAttribute = true
1210
- startObject[attr.name] = starts
1223
+ startObject[attrName] = starts
1211
1224
  }
1212
1225
  })
1213
1226
  })
@@ -1215,51 +1228,52 @@ export const render = (el, contexts = {}, notRender, isName) => {
1215
1228
  const isAcomponent=el._componentName?true:false
1216
1229
 
1217
1230
  el._attributes.forEach(attr => {
1218
-
1231
+ let attrName=attr.name.replace(/^-+/, '');
1232
+ attrName=attrName.trim()
1219
1233
  if (stopResume.stop || el._hasRun) return
1220
- if (directives[attr.name]) {
1221
- directives[attr.name](el, attr, stateContext)
1222
- } else if (attr.name.startsWith('on-') && !isAcomponent) {
1234
+ if (directives[attrName]) {
1235
+ directives[attrName](el, attr, stateContext)
1236
+ } else if (attrName.startsWith('on-') && !isAcomponent) {
1223
1237
  event(el, attr, stateContext)
1224
- } else if ((attr.value.includes('@{') || attr.name.startsWith('@')) && !attr.name.startsWith('c-at-')) {
1238
+ } else if ((attr.value.includes('@{') || attrName.startsWith('@')) && !attrName.startsWith('c-at-')) {
1225
1239
  mainAttribute(el, attr, isName)
1226
- } else if (attr.name.startsWith('state-')) {
1240
+ } else if (attrName.startsWith('state-')) {
1227
1241
  States(el, attr, getCurrentContext())
1228
- } else if (attr.name.startsWith('out-') && !isAcomponent) {
1242
+ } else if (attrName.startsWith('out-') && !isAcomponent) {
1229
1243
  documentEvent(el, attr)
1230
- } else if (attr.name.startsWith('after-[') && attr.name.endsWith(']') && !isAcomponent) {
1244
+ } else if (attrNamestartsWith('after-[') && attrName.endsWith(']') && !isAcomponent) {
1231
1245
  After(el, attr)
1232
1246
  }
1233
- else if (attr.name.startsWith('every-[') && attr.name.endsWith(']') && !isAcomponent) {
1247
+ else if (attrName.startsWith('every-[') && attrName.endsWith(']') && !isAcomponent) {
1234
1248
  Every(el, attr)
1235
1249
  }
1236
- else if (attr.name.startsWith('c-c-')) {
1250
+ else if (attrName.startsWith('c-c-')) {
1237
1251
  stopResume.stop = true
1238
1252
 
1239
1253
 
1240
1254
  component(el, true, attr, notRender, stopResume)// component continuity
1241
- } else if (attr.name.startsWith('c-at-')) {
1255
+ } else if (attrName.startsWith('c-at-')) {
1242
1256
  resumer.resume_attribute?.(el, attr, notRender) //attribute continuity
1243
- } else if (attr.name.startsWith('c-$-')) {
1257
+ } else if (attrName.startsWith('c-$-')) {
1244
1258
  resumer.resume_state?.(el, attr, notRender) //state continuity
1245
- } else if (attr.name.startsWith('c-t')) {//text continuity
1259
+ } else if (attrName.startsWith('c-t')) {//text continuity
1246
1260
  resumer.resume_text(el, attr, isName)
1247
- } else if (attr.name.startsWith('c-if-')) {
1261
+ } else if (attrName.startsWith('c-if-')) {
1248
1262
  directives['if'](el, attr, stateContext, true, notRender, stopResume)
1249
- } else if (attr.name === 'c-for') {
1263
+ } else if (attrName === 'c-for') {
1250
1264
  directives['for-each'](el, attr, stateContext, true, notRender, stopResume)
1251
- }else if (attr.name.startsWith('c-key-')) {
1265
+ }else if (attrName.startsWith('c-key-')) {
1252
1266
  directives['key'](el, attr, stateContext, true, notRender, stopResume)
1253
1267
  }
1254
- else if (attr.name.startsWith('c-sw-')) {
1268
+ else if (attrName.startsWith('c-sw-')) {
1255
1269
  directives['switch'](el, attr, stateContext, true, notRender, stopResume)// switch continuity
1256
- } else if (fullNamePlugin.has(attr.name)) {
1257
- if (externalPlugin[attr.name]) {
1258
- if (el._componentName && !attr.name.startsWith('c-'))return
1259
- const plugin = externalPlugin[attr.name]
1270
+ } else if (fullNamePlugin.has(attrName)) {
1271
+ if (externalPlugin[attrName]) {
1272
+ if (el._componentName && !attrName.startsWith('c-'))return
1273
+ const plugin = externalPlugin[attrName]
1260
1274
  try {
1261
1275
  if (typeof plugin !== 'function') {
1262
- console.warn(`${attr.name} plugin must be a function`)
1276
+ console.warn(`${attrName} plugin must be a function`)
1263
1277
  return
1264
1278
  }
1265
1279
  plugin(el, attr, stateContext, notRender, stopResume)
@@ -1268,9 +1282,9 @@ export const render = (el, contexts = {}, notRender, isName) => {
1268
1282
  }
1269
1283
  }
1270
1284
  } else if (startAttribute) {
1271
- const name = startObject[attr.name]
1285
+ const name = startObject[attrName]
1272
1286
  if (externalPlugin[name]) {
1273
- if (el._componentName && !attr.name.startsWith('c-'))return
1287
+ if (el._componentName && !attrName.startsWith('c-'))return
1274
1288
  const plugin = externalPlugin[name]
1275
1289
  try {
1276
1290
  if (typeof plugin !== 'function') {
@@ -1360,7 +1374,10 @@ if (typeof window !== 'undefined') {
1360
1374
 
1361
1375
  }
1362
1376
  export const pawaStartApp = (app, context = {}) => {
1363
- render(app, context)
1377
+ if (app?.tagName && app.hasAttribute('pawa-app') === false) {
1378
+ app.setAttribute('pawa-app', '')
1379
+ render(app, context)
1380
+ }
1364
1381
  }
1365
1382
 
1366
1383
  /**
@@ -1393,6 +1410,7 @@ const Pawa = {
1393
1410
  RegisterComponent,
1394
1411
  runEffect,
1395
1412
  html,
1413
+ accessChild,
1396
1414
  PawaCustomEvent
1397
1415
  }
1398
1416
 
@@ -83,19 +83,26 @@ export const normal_component=(el,stateContext,setStateContext,mapsPlugin,former
83
83
  let compo
84
84
  let awaits=false
85
85
  let suspense=''
86
-
86
+ let elementContext=el._context
87
87
  if (__pawaDev.tool) {
88
- const id= crypto.randomUUID()
89
- if (HmrComponentMap.has(stateContexts.component._filePath) && stateContexts.component._filePath) {
90
- HmrComponentMap.get(stateContexts.component._filePath).push({id:id,template:el._template,el:el,stateContext:stateContexts})
88
+ const id=Date.now() + Math.random()
89
+ if (HmrComponentMap.has(el._componentName)) {
90
+ HmrComponentMap.get(el._componentName).push({id:id,template:el._template,el:el,stateContext:stateContexts,remove:()=>{
91
+ return pawaWayRemover(comment,endComment)
92
+ },context:elementContext,comment:comment
93
+ })
91
94
  }else{
92
- HmrComponentMap.set(stateContexts.component._filePath,[{id:id,template:el._template,el:el,stateContext:stateContexts}])
95
+ HmrComponentMap.set(el._componentName,[{id:id,template:el._template,el:el,stateContext:stateContexts,remove:()=>{
96
+ return pawaWayRemover(comment,endComment)
97
+ },context:elementContext,comment:comment}])
93
98
  }
94
99
  el._setUnMount(()=>{
95
- const array=HmrComponentMap.get(stateContexts.component._filePath)
100
+ const array=HmrComponentMap.get(el._componentName)
96
101
  if(array){
97
102
  const index=array.findIndex(item => item.id === id)
98
103
  if(index !== -1) array.splice(index,1)
104
+ }else{
105
+ HmrComponentMap.delete(el._componentName)
99
106
  }
100
107
  })
101
108
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "pawajs",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "type":"module",
5
- "description": "pawajs library (reactive web runtime) for easily building web ui, enhancing html element, micro frontend etc ",
5
+ "description": "pawajs library (reactive web runtime) for easily building web ui, enhancing html element, micro frontend, spa etc ",
6
6
  "main": "index.js",
7
7
  "scripts": {
8
8
  "test": "echo \"Error: no test specified\" && exit 1"
package/pawaElement.js CHANGED
@@ -10,6 +10,7 @@ import { lazyComponentElement } from './index.js';
10
10
  export class PawaElement {
11
11
 
12
12
  #context
13
+ #el
13
14
  /**
14
15
  *
15
16
  * @param {HTMLElement} element
@@ -17,10 +18,11 @@ export class PawaElement {
17
18
  */
18
19
  constructor(element,context) {
19
20
  this.#context=context
21
+ this.#el=element
20
22
  const div=element.cloneNode(true)
21
23
  Object.assign(this, {
22
24
  _resetEffects: new Set(), _context: context, _avoidPawaRender: element.hasAttribute('pawa-avoid'),
23
- _el: element, _out: false, _stateContext: null, _terminateEffects: new Set(), _deleteEffects: this.terminateEffects,
25
+ _out: false, _stateContext: null, _terminateEffects: new Set(), _deleteEffects: this.terminateEffects,
24
26
  _slots: document.createDocumentFragment(), _mainAttribute: {}, _preRenderAvoid: [], _running: false,
25
27
  _hasForOrIf: this.hasForOrIf, _elementContent: element.textContent, _textContent: {}, _attributes: [],
26
28
  _template: div.outerHTML, _exitAnimation: null, _component: null, _unMountFunctions: [], _MountFunctions: [],_beforeUnMountFunctions:[],
@@ -48,13 +50,13 @@ export class PawaElement {
48
50
  Object.assign(element,pawa)
49
51
  }
50
52
  getChildrenTree(){
51
- return Array.from(this._el.children)
53
+ return Array.from(this.#el.children)
52
54
  }
53
55
  checkLazy(){
54
- if (lazyComponents.has(splitAndAdd(this._el.tagName))) {
55
- if(components.has(splitAndAdd(this._el.tagName))) return
56
+ if (lazyComponents.has(splitAndAdd(this.#el.tagName))) {
57
+ if(components.has(splitAndAdd(this.#el.tagName))) return
56
58
  this._lazy=true
57
- triggerLazyLoad(splitAndAdd(this._el.tagName))
59
+ triggerLazyLoad(splitAndAdd(this.#el.tagName))
58
60
 
59
61
  }
60
62
  }
@@ -75,6 +77,8 @@ export class PawaElement {
75
77
  }
76
78
 
77
79
  }catch(error){
80
+ throw new Error(`Error evaluating expression: ${expression}\n${error.message}`);
81
+
78
82
  __pawaDev.setError({
79
83
  el:this?._el,
80
84
  msg:`from ${expression}`,
@@ -91,24 +95,24 @@ export class PawaElement {
91
95
  })
92
96
  }
93
97
  setPawaAttr(){
94
- const isResume=this._el.hasAttribute('p:c')
95
- if (this._el.hasAttribute('p-async')) return
98
+ const isResume=this.#el.hasAttribute('p:c')
99
+ if (this.#el.hasAttribute('p-async')) return
96
100
  if(isResume){
97
- const pawaAttr=this._el.getAttribute('p:c')
101
+ const pawaAttr=this.#el.getAttribute('p:c')
98
102
  const array=pawaAttr.split(';')
99
103
  array.forEach(value =>{
100
- if(!this._el.hasAttribute(value.toLowerCase())) {
104
+ if(!this.#el.hasAttribute(value.toLowerCase())) {
101
105
  return
102
106
  }
103
- this._attributes.push({name:value,value:this._el.getAttribute(value.toLowerCase())})
104
- // console.log(this._el,this._attributes);
107
+ this._attributes.push({name:value,value:this.#el.getAttribute(value.toLowerCase())})
108
+ // console.log(this.#el,this._attributes);
105
109
  })
106
110
  }else{
107
- this._attributes=Array.from(this._el.attributes)
111
+ this._attributes=Array.from(this.#el.attributes)
108
112
  }
109
113
  }
110
114
  findPawaAttribute(){
111
- Array.from(this._el.attributes).forEach((attr) => {
115
+ Array.from(this.#el.attributes).forEach((attr) => {
112
116
  const pawaAttribute=getPawaAttributes()
113
117
  const dependentAttribute=getDependentAttribute()
114
118
  if (pawaAttribute.has(attr.name) && !dependentAttribute.has(attr.name)) {
@@ -141,7 +145,7 @@ export class PawaElement {
141
145
  }
142
146
 
143
147
  getNewElementByRemovingAttr(attrName){
144
- const element=this._el.cloneNode(true)
148
+ const element=this.#el.cloneNode(true)
145
149
  element.removeAttribute(attrName)
146
150
  return element
147
151
  }
@@ -177,8 +181,10 @@ export class PawaElement {
177
181
  async remove(callback){
178
182
 
179
183
  await this._beforeUnMount()
184
+ if (window?.hmr) {
185
+ this._exitAnimation=null
186
+ }
180
187
  if (typeof this._exitAnimation === 'function') {
181
-
182
188
  try {
183
189
  const animate=this._exitAnimation().then(async () => {
184
190
  await this._callUnmount()
@@ -250,21 +256,21 @@ export class PawaElement {
250
256
  if (this._avoidPawaRender) {
251
257
  return
252
258
  }
253
- const tag = this._el.tagName
259
+ const tag = this.#el.tagName
254
260
  try {
255
- if (components.has(splitAndAdd(tag)) || this._lazy && !this._el.hasAttribute('data-prevent:c')) {
261
+ if (components.has(splitAndAdd(tag)) || this._lazy && !this.#el.hasAttribute('data-prevent:c')) {
256
262
  this._elementType='component'
257
263
  this._componentOrTemplate=true
258
264
  this._deCompositionElement=true
259
265
  this._componentName=splitAndAdd(tag)
260
266
  const forLazy=()=>true
261
267
  this._component=new PawaComponent(components.get(splitAndAdd(tag)) || forLazy)
262
- Array.from(this._el.children).forEach(slot =>{
268
+ Array.from(this.#el.children).forEach(slot =>{
263
269
  if (slot.tagName === 'TEMPLATE' && slot.getAttribute('prop') && !slot.hasAttribute('js')) {
264
270
  this._slots.appendChild(slot)
265
271
  }
266
272
  })
267
- this._componentChildren=this._el.innerHTML
273
+ this._componentChildren=this.#el.innerHTML
268
274
 
269
275
  } else if(tag ==='TEMPLATE'){
270
276
  this._elementType='template'
@@ -293,9 +299,9 @@ export class PawaElement {
293
299
  return
294
300
  }
295
301
  if (this._componentName) {
296
- const hasPC=this._el.hasAttribute('p:c')
302
+ const hasPC=this.#el.hasAttribute('p:c')
297
303
  if (hasPC) {
298
- Array.from(this._el.attributes).forEach(attr => {
304
+ Array.from(this.#el.attributes).forEach(attr => {
299
305
  if (attr.name.startsWith('c-') || attr.name === 'by') return
300
306
  this._attributes.push({name:attr.name,value:attr.value})
301
307
  });
@@ -319,6 +325,7 @@ export class PawaElement {
319
325
  name=attr.name
320
326
  }
321
327
  const context=this._context
328
+ const main={...context}
322
329
  const setProps=()=>{
323
330
  delete this._restProps[name]
324
331
  let value=attr.value
@@ -328,7 +335,7 @@ export class PawaElement {
328
335
  if (checkKeywordsExistence(this._staticContext, expression)) {
329
336
  return value
330
337
  } else {
331
- const res = this.safeEval(context, expression, 'props', true)
338
+ const res = this.safeEval({...main}, expression, 'props', true)
332
339
  return res
333
340
  }
334
341
  });
package/power.js CHANGED
@@ -104,7 +104,8 @@ const processEventExecution = (el, attrName, modifiers, callback, eventType, dir
104
104
  const execute = () => {
105
105
  try { callback(); }
106
106
  catch (error) {
107
- console.log(error,'at event')
107
+ throw new Error(error,`at ${attrName} from ${el._template}`);
108
+
108
109
  setPawaDevError({ message: `Error from ${directiveName}-${eventType} directive ${error.message}`, error, template: el._template }); }
109
110
  };
110
111
  if (!el._eventTimers) el._eventTimers = {};
@@ -352,8 +353,9 @@ const createBoundCallback = (el, code,context) => {
352
353
  const keys = Object.keys(context);
353
354
  const resolvePath = (path, obj) => path.split('.').reduce((acc, key) => acc?.[key], obj);
354
355
  const values = keys.map((key) => resolvePath(key, context));
355
- const func = new Function(...keys, code);
356
- return () => func(...values);
356
+ const func = new Function('$el',...keys, code);
357
+ const $el=el
358
+ return () => func($el,...values);
357
359
  };
358
360
 
359
361
  export const mountElement = (el, attr) => {