pawa-ssr 1.2.8 → 1.2.9
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 +36 -22
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -132,6 +132,7 @@ const useInnerContext=()=>{
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
|
|
135
136
|
const $state = (initialValue) => {
|
|
136
137
|
const state = { value: null };
|
|
137
138
|
if (typeof initialValue === 'function') {
|
|
@@ -882,17 +883,29 @@ const attributeHandler =async (el, attr) => {
|
|
|
882
883
|
string.forEach(v => singleElement.add(v))
|
|
883
884
|
}
|
|
884
885
|
setSingle('img','br')
|
|
886
|
+
const partlyPawajsDirective=new Set()
|
|
887
|
+
export const addToPartlyDirective=(...partly)=>{
|
|
888
|
+
partly.forEach((v)=>{
|
|
889
|
+
partlyPawajsDirective.add(v)
|
|
890
|
+
})
|
|
891
|
+
}
|
|
892
|
+
addToPartlyDirective('else','else-if','case')
|
|
893
|
+
const checkIfRemove=(el)=>{
|
|
894
|
+
for (const v of partlyPawajsDirective) {
|
|
895
|
+
if(el.hasAttribute(v)) return true
|
|
896
|
+
}
|
|
897
|
+
return false
|
|
898
|
+
}
|
|
885
899
|
/**
|
|
886
900
|
*
|
|
887
901
|
* @param {PawaElement | HTMLElement} el
|
|
888
902
|
* @param {object} contexts
|
|
889
903
|
*/
|
|
890
904
|
export const render =async (el, contexts = {},stream) => {
|
|
891
|
-
|
|
892
|
-
if (!el.
|
|
905
|
+
|
|
906
|
+
if (!el.parentNode && checkIfRemove(el)) {
|
|
893
907
|
return
|
|
894
908
|
}
|
|
895
|
-
|
|
896
909
|
const isStream=store.getStore().stream
|
|
897
910
|
if(el.hasAttribute('only-client')){
|
|
898
911
|
el.removeAttribute('only-client')
|
|
@@ -933,17 +946,17 @@ export const render =async (el, contexts = {},stream) => {
|
|
|
933
946
|
const startObject={}
|
|
934
947
|
//get startsWith plugin
|
|
935
948
|
if (!el._avoidPawaRender) {
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
949
|
+
startsWithSet.forEach( starts=>{
|
|
950
|
+
|
|
951
|
+
el._attributes.forEach(attr =>{
|
|
952
|
+
if(attr.name.startsWith(starts)){
|
|
953
|
+
startAttribute=true
|
|
954
|
+
startObject[attr.name]=starts
|
|
955
|
+
}
|
|
956
|
+
})
|
|
957
|
+
})
|
|
958
|
+
}
|
|
959
|
+
for (const fn of renderAfterPawa) {
|
|
947
960
|
try {
|
|
948
961
|
await fn(el)
|
|
949
962
|
} catch (error) {
|
|
@@ -954,14 +967,14 @@ export const render =async (el, contexts = {},stream) => {
|
|
|
954
967
|
|
|
955
968
|
const attributes = Array.from(el.attributes);
|
|
956
969
|
for(const attr of attributes){
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
970
|
+
if (directives[attr.name]) {
|
|
971
|
+
await directives[attr.name](el,attr,stream)
|
|
972
|
+
}else if(attr.value.includes('@{')){
|
|
973
|
+
await attributeHandler(el,attr)
|
|
974
|
+
}else if (attr.name.startsWith('state-')) {
|
|
975
|
+
directives['state-'](el,attr)
|
|
976
|
+
}
|
|
977
|
+
else if(fullNamePlugin.has(attr.name)) {
|
|
965
978
|
if(externalPlugin[attr.name]){
|
|
966
979
|
const plugin= externalPlugin[attr.name]
|
|
967
980
|
try{
|
|
@@ -991,6 +1004,7 @@ export const render =async (el, contexts = {},stream) => {
|
|
|
991
1004
|
}
|
|
992
1005
|
|
|
993
1006
|
}
|
|
1007
|
+
// If the element is not connected and has no parent, it means it was removed (e.g. by If directive)
|
|
994
1008
|
if(el.tagName === 'TEMPLATE'){
|
|
995
1009
|
await templates(el,stream)
|
|
996
1010
|
return
|