regor 1.6.9 → 1.7.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/dist/regor.d.ts +1 -0
- package/dist/regor.es2015.cjs.js +164 -121
- package/dist/regor.es2015.cjs.prod.js +3 -3
- package/dist/regor.es2015.esm.js +164 -121
- package/dist/regor.es2015.esm.prod.js +3 -3
- package/dist/regor.es2015.iife.js +164 -121
- package/dist/regor.es2015.iife.prod.js +3 -3
- package/dist/regor.es2019.cjs.js +164 -121
- package/dist/regor.es2019.cjs.prod.js +3 -3
- package/dist/regor.es2019.esm.js +164 -121
- package/dist/regor.es2019.esm.prod.js +3 -3
- package/dist/regor.es2019.iife.js +164 -121
- package/dist/regor.es2019.iife.prod.js +3 -3
- package/dist/regor.es2022.cjs.js +162 -120
- package/dist/regor.es2022.cjs.prod.js +3 -3
- package/dist/regor.es2022.esm.js +162 -120
- package/dist/regor.es2022.esm.prod.js +3 -3
- package/dist/regor.es2022.iife.js +162 -120
- package/dist/regor.es2022.iife.prod.js +3 -3
- package/package.json +1 -1
package/dist/regor.es2022.esm.js
CHANGED
|
@@ -1115,6 +1115,131 @@ var isScope = (value) => {
|
|
|
1115
1115
|
return scopeSymbol2 in value;
|
|
1116
1116
|
};
|
|
1117
1117
|
|
|
1118
|
+
// src/reactivity/unref.ts
|
|
1119
|
+
var unref = (value) => {
|
|
1120
|
+
const anyValue = value;
|
|
1121
|
+
return anyValue != null && anyValue[srefSymbol] > 0 ? anyValue() : anyValue;
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
// src/directives/attr.ts
|
|
1125
|
+
var xlinkNS = "http://www.w3.org/1999/xlink";
|
|
1126
|
+
var booleanAttributes = {
|
|
1127
|
+
itemscope: 2,
|
|
1128
|
+
allowfullscreen: 2,
|
|
1129
|
+
formnovalidate: 2,
|
|
1130
|
+
ismap: 2,
|
|
1131
|
+
nomodule: 2,
|
|
1132
|
+
novalidate: 2,
|
|
1133
|
+
readonly: 2,
|
|
1134
|
+
async: 1,
|
|
1135
|
+
autofocus: 1,
|
|
1136
|
+
autoplay: 1,
|
|
1137
|
+
controls: 1,
|
|
1138
|
+
default: 1,
|
|
1139
|
+
defer: 1,
|
|
1140
|
+
disabled: 1,
|
|
1141
|
+
hidden: 1,
|
|
1142
|
+
inert: 1,
|
|
1143
|
+
loop: 1,
|
|
1144
|
+
open: 1,
|
|
1145
|
+
required: 1,
|
|
1146
|
+
reversed: 1,
|
|
1147
|
+
scoped: 1,
|
|
1148
|
+
seamless: 1,
|
|
1149
|
+
checked: 1,
|
|
1150
|
+
muted: 1,
|
|
1151
|
+
multiple: 1,
|
|
1152
|
+
selected: 1
|
|
1153
|
+
};
|
|
1154
|
+
var updateAttr = (el, values, previousValues, option, previousOption, flags) => {
|
|
1155
|
+
if (option) {
|
|
1156
|
+
option = unref(option);
|
|
1157
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
1158
|
+
patchAttr(
|
|
1159
|
+
el,
|
|
1160
|
+
option,
|
|
1161
|
+
unref(values[0]),
|
|
1162
|
+
unref(previousOption)
|
|
1163
|
+
);
|
|
1164
|
+
return;
|
|
1165
|
+
}
|
|
1166
|
+
const len = values.length;
|
|
1167
|
+
for (let i = 0; i < len; ++i) {
|
|
1168
|
+
const next = values[i];
|
|
1169
|
+
if (isArray(next)) {
|
|
1170
|
+
const previousKey = unref(previousValues?.[i]?.[0]);
|
|
1171
|
+
const key = unref(next[0]);
|
|
1172
|
+
const value = unref(next[1]);
|
|
1173
|
+
patchAttr(el, key, value, previousKey);
|
|
1174
|
+
} else if (isObject(next)) {
|
|
1175
|
+
for (const item of Object.entries(next)) {
|
|
1176
|
+
const key = item[0];
|
|
1177
|
+
const value = unref(item[1]);
|
|
1178
|
+
const p = unref(previousValues?.[i]);
|
|
1179
|
+
const previousKey = p && key in p ? key : void 0;
|
|
1180
|
+
patchAttr(el, key, value, previousKey);
|
|
1181
|
+
}
|
|
1182
|
+
} else {
|
|
1183
|
+
const previousKey = unref(previousValues?.[i]);
|
|
1184
|
+
const key = unref(values[i++]);
|
|
1185
|
+
const value = unref(values[i]);
|
|
1186
|
+
patchAttr(el, key, value, previousKey);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
var attrDirective = {
|
|
1191
|
+
mount: () => ({
|
|
1192
|
+
update: ({ el, values, previousValues, option, previousOption, flags }) => {
|
|
1193
|
+
updateAttr(
|
|
1194
|
+
el,
|
|
1195
|
+
values,
|
|
1196
|
+
previousValues,
|
|
1197
|
+
option,
|
|
1198
|
+
previousOption,
|
|
1199
|
+
flags
|
|
1200
|
+
);
|
|
1201
|
+
}
|
|
1202
|
+
})
|
|
1203
|
+
};
|
|
1204
|
+
var patchAttr = (el, key, value, previousKey) => {
|
|
1205
|
+
if (previousKey && previousKey !== key) {
|
|
1206
|
+
el.removeAttribute(previousKey);
|
|
1207
|
+
}
|
|
1208
|
+
if (isNullOrUndefined(key)) {
|
|
1209
|
+
warning(3 /* KeyIsEmpty */, "r-bind", el);
|
|
1210
|
+
return;
|
|
1211
|
+
}
|
|
1212
|
+
if (!isString(key)) {
|
|
1213
|
+
warning(
|
|
1214
|
+
6 /* ErrorLog */,
|
|
1215
|
+
`Attribute key is not string at ${el.outerHTML}`,
|
|
1216
|
+
key
|
|
1217
|
+
);
|
|
1218
|
+
return;
|
|
1219
|
+
}
|
|
1220
|
+
if (key.startsWith("xlink:")) {
|
|
1221
|
+
if (isNullOrUndefined(value)) {
|
|
1222
|
+
el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
|
1223
|
+
} else {
|
|
1224
|
+
el.setAttributeNS(xlinkNS, key, value);
|
|
1225
|
+
}
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
if (isNullOrUndefined(value)) {
|
|
1229
|
+
el.removeAttribute(key);
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1232
|
+
if (key in booleanAttributes) {
|
|
1233
|
+
if (toBoolean(value)) {
|
|
1234
|
+
el.setAttribute(key, "");
|
|
1235
|
+
} else {
|
|
1236
|
+
el.removeAttribute(key);
|
|
1237
|
+
}
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
el.setAttribute(key, value);
|
|
1241
|
+
};
|
|
1242
|
+
|
|
1118
1243
|
// src/directives/context.ts
|
|
1119
1244
|
var contextDirective = {
|
|
1120
1245
|
collectRefObj: true,
|
|
@@ -1845,10 +1970,11 @@ var ComponentBinder = class {
|
|
|
1845
1970
|
} else if (attrName === ":style" || attrName === bindStyleName) {
|
|
1846
1971
|
mergeBinding(":style", bindStyleName, value);
|
|
1847
1972
|
} else {
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1973
|
+
const normalizedName = normalizeAttributeName(
|
|
1974
|
+
attrName,
|
|
1975
|
+
binder.__config
|
|
1851
1976
|
);
|
|
1977
|
+
patchAttr(inheritor, normalizedName, value);
|
|
1852
1978
|
}
|
|
1853
1979
|
};
|
|
1854
1980
|
for (const { name, value } of inheritedPropAttrs) {
|
|
@@ -2184,12 +2310,6 @@ var DynamicBinder = class {
|
|
|
2184
2310
|
}
|
|
2185
2311
|
};
|
|
2186
2312
|
|
|
2187
|
-
// src/reactivity/unref.ts
|
|
2188
|
-
var unref = (value) => {
|
|
2189
|
-
const anyValue = value;
|
|
2190
|
-
return anyValue != null && anyValue[srefSymbol] > 0 ? anyValue() : anyValue;
|
|
2191
|
-
};
|
|
2192
|
-
|
|
2193
2313
|
// src/directives/html.ts
|
|
2194
2314
|
var updateHtml = (el, values) => {
|
|
2195
2315
|
const [value, replacer] = values;
|
|
@@ -3125,115 +3245,6 @@ var Binder = class {
|
|
|
3125
3245
|
}
|
|
3126
3246
|
};
|
|
3127
3247
|
|
|
3128
|
-
// src/directives/attr.ts
|
|
3129
|
-
var xlinkNS = "http://www.w3.org/1999/xlink";
|
|
3130
|
-
var booleanAttributes = {
|
|
3131
|
-
itemscope: 2,
|
|
3132
|
-
allowfullscreen: 2,
|
|
3133
|
-
formnovalidate: 2,
|
|
3134
|
-
ismap: 2,
|
|
3135
|
-
nomodule: 2,
|
|
3136
|
-
novalidate: 2,
|
|
3137
|
-
readonly: 2,
|
|
3138
|
-
async: 1,
|
|
3139
|
-
autofocus: 1,
|
|
3140
|
-
autoplay: 1,
|
|
3141
|
-
controls: 1,
|
|
3142
|
-
default: 1,
|
|
3143
|
-
defer: 1,
|
|
3144
|
-
disabled: 1,
|
|
3145
|
-
hidden: 1,
|
|
3146
|
-
inert: 1,
|
|
3147
|
-
loop: 1,
|
|
3148
|
-
open: 1,
|
|
3149
|
-
required: 1,
|
|
3150
|
-
reversed: 1,
|
|
3151
|
-
scoped: 1,
|
|
3152
|
-
seamless: 1,
|
|
3153
|
-
checked: 1,
|
|
3154
|
-
muted: 1,
|
|
3155
|
-
multiple: 1,
|
|
3156
|
-
selected: 1
|
|
3157
|
-
};
|
|
3158
|
-
function includeBooleanAttr(value) {
|
|
3159
|
-
return !!value || value === "";
|
|
3160
|
-
}
|
|
3161
|
-
var updateAttr = (el, values, previousValues, option, previousOption, flags) => {
|
|
3162
|
-
if (option) {
|
|
3163
|
-
if (flags && flags.includes("camel")) option = camelize(option);
|
|
3164
|
-
patchAttribute(el, option, values[0], previousOption);
|
|
3165
|
-
return;
|
|
3166
|
-
}
|
|
3167
|
-
const len = values.length;
|
|
3168
|
-
for (let i = 0; i < len; ++i) {
|
|
3169
|
-
const next = values[i];
|
|
3170
|
-
if (isArray(next)) {
|
|
3171
|
-
const previousKey = previousValues?.[i]?.[0];
|
|
3172
|
-
const key = next[0];
|
|
3173
|
-
const value = next[1];
|
|
3174
|
-
patchAttribute(el, key, value, previousKey);
|
|
3175
|
-
} else if (isObject(next)) {
|
|
3176
|
-
for (const item of Object.entries(next)) {
|
|
3177
|
-
const key = item[0];
|
|
3178
|
-
const value = item[1];
|
|
3179
|
-
const p = previousValues?.[i];
|
|
3180
|
-
const previousKey = p && key in p ? key : void 0;
|
|
3181
|
-
patchAttribute(el, key, value, previousKey);
|
|
3182
|
-
}
|
|
3183
|
-
} else {
|
|
3184
|
-
const previousKey = previousValues?.[i];
|
|
3185
|
-
const key = values[i++];
|
|
3186
|
-
const value = values[i];
|
|
3187
|
-
patchAttribute(el, key, value, previousKey);
|
|
3188
|
-
}
|
|
3189
|
-
}
|
|
3190
|
-
};
|
|
3191
|
-
var attrDirective = {
|
|
3192
|
-
mount: () => ({
|
|
3193
|
-
update: ({ el, values, previousValues, option, previousOption, flags }) => {
|
|
3194
|
-
updateAttr(
|
|
3195
|
-
el,
|
|
3196
|
-
values,
|
|
3197
|
-
previousValues,
|
|
3198
|
-
option,
|
|
3199
|
-
previousOption,
|
|
3200
|
-
flags
|
|
3201
|
-
);
|
|
3202
|
-
}
|
|
3203
|
-
})
|
|
3204
|
-
};
|
|
3205
|
-
var patchAttribute = (el, key, value, previousKey) => {
|
|
3206
|
-
if (previousKey && previousKey !== key) {
|
|
3207
|
-
el.removeAttribute(previousKey);
|
|
3208
|
-
}
|
|
3209
|
-
if (isNullOrUndefined(key)) {
|
|
3210
|
-
warning(3 /* KeyIsEmpty */, "r-bind", el);
|
|
3211
|
-
return;
|
|
3212
|
-
}
|
|
3213
|
-
if (!isString(key)) {
|
|
3214
|
-
warning(
|
|
3215
|
-
6 /* ErrorLog */,
|
|
3216
|
-
`Attribute key is not string at ${el.outerHTML}`,
|
|
3217
|
-
key
|
|
3218
|
-
);
|
|
3219
|
-
return;
|
|
3220
|
-
}
|
|
3221
|
-
if (key.startsWith("xlink:")) {
|
|
3222
|
-
if (isNullOrUndefined(value)) {
|
|
3223
|
-
el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
|
3224
|
-
} else {
|
|
3225
|
-
el.setAttributeNS(xlinkNS, key, value);
|
|
3226
|
-
}
|
|
3227
|
-
return;
|
|
3228
|
-
}
|
|
3229
|
-
const isBoolean2 = key in booleanAttributes;
|
|
3230
|
-
if (isNullOrUndefined(value) || isBoolean2 && !includeBooleanAttr(value)) {
|
|
3231
|
-
el.removeAttribute(key);
|
|
3232
|
-
} else {
|
|
3233
|
-
el.setAttribute(key, isBoolean2 ? "" : value);
|
|
3234
|
-
}
|
|
3235
|
-
};
|
|
3236
|
-
|
|
3237
3248
|
// src/directives/class.ts
|
|
3238
3249
|
var updateClass = (el, values, previousValues) => {
|
|
3239
3250
|
const len = values.length;
|
|
@@ -3615,8 +3626,10 @@ var handleRadio = (el, getModelRef) => {
|
|
|
3615
3626
|
};
|
|
3616
3627
|
var handleSelect = (el, getModelRef, parsedValue) => {
|
|
3617
3628
|
const eventType = "change";
|
|
3629
|
+
const stopObservingOptions = observeSelectOptions(el, parsedValue);
|
|
3618
3630
|
const unbinder = () => {
|
|
3619
3631
|
el.removeEventListener(eventType, listener);
|
|
3632
|
+
stopObservingOptions();
|
|
3620
3633
|
};
|
|
3621
3634
|
const listener = () => {
|
|
3622
3635
|
const modelRef = getModelRef();
|
|
@@ -3650,6 +3663,35 @@ var handleSelect = (el, getModelRef, parsedValue) => {
|
|
|
3650
3663
|
el.addEventListener(eventType, listener);
|
|
3651
3664
|
return unbinder;
|
|
3652
3665
|
};
|
|
3666
|
+
var observeSelectOptions = (el, parsedValue) => {
|
|
3667
|
+
const MutationObserverCtor = globalThis.MutationObserver ?? globalThis.window?.MutationObserver;
|
|
3668
|
+
if (!MutationObserverCtor) return () => {
|
|
3669
|
+
};
|
|
3670
|
+
let pending = false;
|
|
3671
|
+
let stopped = false;
|
|
3672
|
+
const flush = () => {
|
|
3673
|
+
pending = false;
|
|
3674
|
+
if (stopped) return;
|
|
3675
|
+
updateDomElementValue(el, parsedValue()[0]);
|
|
3676
|
+
};
|
|
3677
|
+
const scheduleFlush = () => {
|
|
3678
|
+
if (pending) return;
|
|
3679
|
+
pending = true;
|
|
3680
|
+
if (typeof queueMicrotask === "function") queueMicrotask(flush);
|
|
3681
|
+
else Promise.resolve().then(flush);
|
|
3682
|
+
};
|
|
3683
|
+
const observer = new MutationObserverCtor(scheduleFlush);
|
|
3684
|
+
observer.observe(el, {
|
|
3685
|
+
attributes: true,
|
|
3686
|
+
attributeFilter: ["value"],
|
|
3687
|
+
childList: true,
|
|
3688
|
+
subtree: true
|
|
3689
|
+
});
|
|
3690
|
+
return () => {
|
|
3691
|
+
stopped = true;
|
|
3692
|
+
observer.disconnect();
|
|
3693
|
+
};
|
|
3694
|
+
};
|
|
3653
3695
|
|
|
3654
3696
|
// src/directives/on.ts
|
|
3655
3697
|
var availableFlags = [
|
|
@@ -3847,7 +3889,7 @@ var propDirective = {
|
|
|
3847
3889
|
}
|
|
3848
3890
|
})
|
|
3849
3891
|
};
|
|
3850
|
-
function
|
|
3892
|
+
function includeBooleanAttr(value) {
|
|
3851
3893
|
return !!value || value === "";
|
|
3852
3894
|
}
|
|
3853
3895
|
var patchProp = (el, key, value) => {
|
|
@@ -3879,7 +3921,7 @@ var patchProp = (el, key, value) => {
|
|
|
3879
3921
|
if (value === "" || value == null) {
|
|
3880
3922
|
const type = typeof el[key];
|
|
3881
3923
|
if (type === "boolean") {
|
|
3882
|
-
value =
|
|
3924
|
+
value = includeBooleanAttr(value);
|
|
3883
3925
|
} else if (value == null && type === "string") {
|
|
3884
3926
|
value = "";
|
|
3885
3927
|
needRemove = true;
|