pawajs 1.4.36 → 1.4.37

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/index.js CHANGED
@@ -295,7 +295,10 @@ export const createIntersectionObserver = (element, observeBy) => {
295
295
  while (instances.length > 0) {
296
296
  const { element: el, func } = instances.shift();
297
297
  if (el) {
298
- if (el._component) el._component.component = compoFunc;
298
+ if (el._component){
299
+ el._component.component = compoFunc;
300
+ el._component.validPropRule=compoFunc?.validateProps || {}
301
+ }
299
302
 
300
303
  keepContext(el._stateContext);
301
304
  el._stateContext._hasRun = false;
@@ -921,8 +924,9 @@ const component = (el, resume = false, attr, notRender, stopResume) => {
921
924
  if (!lazyComponentElement.has(name)) {
922
925
  createInsectObserver(trackElement,el)
923
926
  }
927
+ }else{
928
+ resumer.resume_component?.(el, attr, setStateContext, mapsPlugins, formerStateContext, pawaContext, stateWatch, { comment, endComment, name, serialized, id, children })
924
929
  }
925
- resumer.resume_component?.(el, attr, setStateContext, mapsPlugins, formerStateContext, pawaContext, stateWatch, { comment, endComment, name, serialized, id, children })
926
930
  }
927
931
  }
928
932
 
package/merger/switch.js CHANGED
@@ -52,7 +52,7 @@ export const merger_switch=(el,attr,stateContext,resume=false,{comment,endCommen
52
52
  }
53
53
  }
54
54
  const setElement=(newElement,exp)=>{
55
- newElement.removeAttribute(exp)
55
+ newElement.removeAttribute(exp === 'default'?'s-default':exp)
56
56
  if (stateContext._hasRun) {
57
57
  stateContext._hasRun = false
58
58
  keepContext(stateContext)
@@ -153,13 +153,15 @@ export const normal_component=(el,stateContext,setStateContext,mapsPlugin,former
153
153
  }
154
154
  const context=el._context
155
155
  const propsSetter=()=>{
156
+ const findElement=div.querySelector('[--]') || div.querySelector('[rest]')
157
+ if (findElement) {
158
+ findElement.removeAttribute('--')
159
+ findElement.removeAttribute('rest')
160
+ }
156
161
  if(Object.entries(el._restProps).length > 0){
157
- const findElement=div.querySelector('[--]') || div.querySelector('[rest]')
158
162
  if (findElement) {
159
163
  for (const [key,value] of Object.entries(el._restProps)) {
160
164
  findElement.setAttribute(value.name,value.value)
161
- findElement.removeAttribute('--')
162
- findElement.removeAttribute('rest')
163
165
  }
164
166
  }
165
167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pawajs",
3
- "version": "1.4.36",
3
+ "version": "1.4.37",
4
4
  "type":"module",
5
5
  "description": "pawajs library (reactive web runtime) for easily building web ui, enhancing html element, micro frontend etc ",
6
6
  "main": "index.js",
package/pawaElement.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import {components,lazyComponents ,escapePawaAttribute,getPawaAttributes,getDependentAttribute,getPrimaryDirectives } from './index.js';
2
- import {splitAndAdd,replaceTemplateOperators,setPawaDevError,getEvalValues} from './utils.js';
2
+ import {splitAndAdd,replaceTemplateOperators,setPawaDevError,getEvalValues, checkKeywordsExistence} from './utils.js';
3
3
  import PawaComponent from './pawaComponent.js';
4
4
  import { createIntersectionObserver } from './index.js';
5
5
  import { addLazyComponentElement } from './index.js';
@@ -293,14 +293,49 @@ export class PawaElement {
293
293
  const pawaAttribute=getPawaAttributes()
294
294
  const dependAttribute=getDependentAttribute()
295
295
  this._attributes.forEach((attr) => {
296
+
296
297
  if (!attr.name.startsWith(':') && !pawaAttribute.has(attr.name) && !dependAttribute.has(attr.name)) {
297
298
  let name=''
298
- if (attr.name.startsWith('-')) {
299
- name=attr.name.slice(1)
300
- } else {
301
- name=attr.name
299
+ if (attr.name.startsWith('-')) {
300
+ name=attr.name.slice(1)
301
+ } else {
302
+ name=attr.name
303
+ }
304
+ const context=this._context
305
+ const setProps=()=>{
306
+ delete this._restProps[name]
307
+ let value=attr.value
308
+ if (value.includes('@{')) {
309
+ const regex = /@{([^}]*)}/g;
310
+ value = value.replace(regex, (match, expression) => {
311
+ if (checkKeywordsExistence(this._staticContext, expression)) {
312
+ return value
313
+ } else {
314
+ const res = this.safeEval(context, expression, 'props', true)
315
+ return res
316
+ }
317
+ });
318
+ return value
319
+ }else if( attr.name.startsWith('on-') || attr.name.startsWith('out-')){
320
+ const res=this.safeEval(context,`(e)=>{
321
+ ${attr.value}
322
+ }`, 'props',true)
323
+ return res
324
+ }
325
+ return attr.value
326
+ }
327
+
328
+ if (this._props[name] || name === 'class' && this._props['className'] || name === 'defaultValue' && this._props['defaultValue']) return
329
+ name=name.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
330
+ if (name === 'class') {
331
+ this._props['className']=setProps
332
+ }else if(name === 'default'){
333
+ this._props['defaultValue']=setProps
334
+ }else{
335
+ this._props[name]=setProps
302
336
  }
303
- this._restProps[name]={name:name,value:attr.value}
337
+
338
+ this._restProps[name]={name:name,value:attr.value}
304
339
  }else if(!pawaAttribute.has(attr.name) && attr.name.startsWith(':')){
305
340
 
306
341
  const propsName=attr.name.slice(1)