pawajs 2.3.5 → 2.4.0-beta.1

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/cdn/index.js CHANGED
@@ -7,7 +7,7 @@ export const Counter=()=>{
7
7
  return html`
8
8
  <div>
9
9
  <h1>Counter APPs</h1>
10
- <h2>@{count.value}</h2>
10
+ <h2 --data="through">@{count.value}</h2>
11
11
  <span if="count.value > 0">positive</span>
12
12
  <span else-if="count.value < 0">negative</span>
13
13
  <span else>It zero</span>
@@ -73,7 +73,7 @@ function restorePawaStateFromContext(oldCtx, newCtx,stateContext,oldStateContext
73
73
  Object.prototype.hasOwnProperty.call(prevInitials, key) &&
74
74
  !sameInitial(prevInitials[key], freshInitials[key])
75
75
 
76
- if (typeof newVal.value === typeof oldVal.value ) {
76
+ if (isPawaState(newVal) && isPawaState(oldVal) && typeof newVal.value === typeof oldVal.value ) {
77
77
  newVal.value = oldVal.value
78
78
  }
79
79
  }
@@ -190,10 +190,7 @@ export const normal_component=(el,stateContext,setStateContext,mapsPlugin,former
190
190
  el._setUnMount(()=>{
191
191
  const array=HmrComponentMap.get(el._componentName)
192
192
  if(array){
193
- const index=array.findIndex(item => item.id === id)
194
- if(index !== -1) array.splice(index,1)
195
- }else{
196
- HmrComponentMap.delete(el._componentName)
193
+ removeFromHmrMap()
197
194
  }
198
195
  })
199
196
  }
@@ -312,8 +309,12 @@ export const normal_component=(el,stateContext,setStateContext,mapsPlugin,former
312
309
  if(Object.entries(restProps).length > 0){
313
310
  if (findElement) {
314
311
  for (const [key,value] of Object.entries(restProps)) {
312
+ if (findElement.hasAttribute(value.name)) {
313
+ findElement.setArribute(`-${value.name}`,value.value)
314
+ }else{
315
315
  findElement.setAttribute(value.name,value.value)
316
316
  }
317
+ }
317
318
  }
318
319
  }
319
320
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "pawajs",
3
- "version": "2.3.5",
4
- "type":"module",
5
- "description": "pawajs library (reactive web runtime) for easily building web ui, enhancing html element, micro frontend, spa etc ",
3
+ "version": "2.4.0-beta.1",
4
+ "type": "module",
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"
@@ -17,7 +17,8 @@
17
17
  "html",
18
18
  "css",
19
19
  "web development",
20
- "ui"
20
+ "ui",
21
+ "runtime"
21
22
  ],
22
23
  "author": "Allwell Oriso-owubo Owupele",
23
24
  "license": "MIT",
@@ -26,4 +27,4 @@
26
27
  },
27
28
  "homepage": "https://pawajs.vercel.app",
28
29
  "website": "https://pawajs.vercel.app"
29
- }
30
+ }
package/pawaElement.js CHANGED
@@ -24,14 +24,13 @@ export class PawaElement {
24
24
  _slots: document.createDocumentFragment(), _mainAttribute: {}, _preRenderAvoid: [], _running: false,
25
25
  _hasForOrIf: this.hasForOrIf, _elementContent: element.textContent, _textContent: {}, _attributes: [],
26
26
  _template: div.outerHTML, _exitAnimation: null, _component: null, _unMountFunctions: [], _MountFunctions: [],_beforeUnMountFunctions:[],
27
- _elementType: '', _getNode: this.getNode, _componentOrTemplate: false, _props: {}, _isView: null,
27
+ _elementType: '', _componentOrTemplate: false, _props: {},
28
28
  _isElementComponent: false, _pawaAttribute: {}, _setUnMount: this.setUnMounts, _componentName: '',_compoToSvg: false,_asChild: false,
29
29
  _attrElement: this.getNewElementByRemovingAttr, _attr: {}, _staticContext: [], _checkStatic: this.reCheckStaticContext,
30
30
  _callMount: this.mount, _callUnmount: this.unMount, _remove: this.remove, _componentChildren: undefined,
31
- _pawaElementComponent: null, _componentTerminate: null, _cacheSetUp: false, _effectsCarrier: null,_beforeUnMount:this.beforeUnMount,
31
+ _pawaElementComponent: null, _componentTerminate: null, _beforeUnMount:this.beforeUnMount,
32
32
  _pawaElementComponentName: '', _reCallEffect: this.reCallEffect, _ElementEffects: new Map(),
33
- _deCompositionElement: false, _restProps: {}, _kill: null, _isKill: false, _scriptFetching: element.hasAttribute('script'),
34
- _scriptDone: false, _underControl: null, safeEval: this.safeEval, _reactiveProps: {},
33
+ _deCompositionElement: false, _restProps: {}, _kill: null, _isKill: false, _underControl: null, safeEval: this.safeEval, _reactiveProps: {},
35
34
  _clearContext:this.clearContext
36
35
  })
37
36
 
@@ -102,11 +101,17 @@ export class PawaElement {
102
101
  if(!this._el.hasAttribute(value.toLowerCase())) {
103
102
  return
104
103
  }
105
- this._attributes.push({name:value,value:this._el.getAttribute(value.toLowerCase())})
104
+ let attrName=value.replace(/^-+/, '');
105
+ attrName=attrName.trim()
106
+ this._attributes.push({name:attrName.startsWith('on-') || attrName === 'ref'?attrName:value,value:this._el.getAttribute(value.toLowerCase())})
106
107
  // console.log(this._el,this._attributes);
107
108
  })
108
109
  }else{
109
- this._attributes=Array.from(this._el.attributes)
110
+ this._attributes=Array.from(this._el.attributes).map((attr)=>{
111
+ let attrName=attr.name.replace(/^-+/, '');
112
+ attrName=attrName.trim()
113
+ return {name:attrName.startsWith('on-') || attrName === 'ref'?attrName:attr.name,value:attr.value}
114
+ })
110
115
  }
111
116
  }
112
117
  findPawaAttribute(){
@@ -130,12 +135,6 @@ export class PawaElement {
130
135
  setUnMounts(func){
131
136
  this._unMountFunctions.push(func)
132
137
  }
133
- getNode(){
134
- const nodeDiv=document.createElement('div')
135
- nodeDiv.innerHTML=this._template
136
- const node=nodeDiv.firstElementChild
137
- return node
138
- }
139
138
  terminateEffects(){
140
139
  this._terminateEffects.forEach((eff) => {
141
140
  eff()
@@ -316,12 +315,7 @@ export class PawaElement {
316
315
  }
317
316
  const primaryAttribute=['if','else','else-if','key','for-each','case','switch','s-default']
318
317
  if (!attr.name.startsWith(':') && !primaryAttribute.includes(attr.name)) {
319
- let name=''
320
- if (attr.name.startsWith('-')) {
321
- name=attr.name.slice(1)
322
- } else {
323
- name=attr.name
324
- }
318
+ let name=attr.name
325
319
  const context=this._context
326
320
  const main={...context}
327
321
  const setProps=()=>{
@@ -338,22 +332,19 @@ export class PawaElement {
338
332
  }
339
333
  });
340
334
  return value
341
- }else if( attr.name.startsWith('on-') || attr.name.startsWith('out-') || attr.name === 'ref'){
342
- const res=this.safeEval(context,`(e)=>{
343
- ${attr.value}
344
- }`, 'props',true)
345
- return res
346
335
  }
347
336
  return attr.value
348
337
  }
349
338
 
350
339
  if (this._props[name] || name === 'class' && this._props['className'] || name === 'defaultValue' && this._props['defaultValue']) return
351
340
  name=name.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
341
+ let attrName=attr.name.replace(/^-+/, '');
342
+ attrName=attrName.trim()
352
343
  if (name === 'class') {
353
344
  this._props['className']=setProps
354
345
  }else if(name === 'default'){
355
346
  this._props['defaultValue']=setProps
356
- }else{
347
+ }else if(!attrName.startsWith('on-') || !attrName.startsWith('ref') || !attrName.startsWith('out-')){
357
348
  this._props[name]=setProps
358
349
  }
359
350