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
|
@@ -1185,6 +1185,131 @@ var Regor = (() => {
|
|
|
1185
1185
|
return scopeSymbol2 in value;
|
|
1186
1186
|
};
|
|
1187
1187
|
|
|
1188
|
+
// src/reactivity/unref.ts
|
|
1189
|
+
var unref = (value) => {
|
|
1190
|
+
const anyValue = value;
|
|
1191
|
+
return anyValue != null && anyValue[srefSymbol] > 0 ? anyValue() : anyValue;
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
// src/directives/attr.ts
|
|
1195
|
+
var xlinkNS = "http://www.w3.org/1999/xlink";
|
|
1196
|
+
var booleanAttributes = {
|
|
1197
|
+
itemscope: 2,
|
|
1198
|
+
allowfullscreen: 2,
|
|
1199
|
+
formnovalidate: 2,
|
|
1200
|
+
ismap: 2,
|
|
1201
|
+
nomodule: 2,
|
|
1202
|
+
novalidate: 2,
|
|
1203
|
+
readonly: 2,
|
|
1204
|
+
async: 1,
|
|
1205
|
+
autofocus: 1,
|
|
1206
|
+
autoplay: 1,
|
|
1207
|
+
controls: 1,
|
|
1208
|
+
default: 1,
|
|
1209
|
+
defer: 1,
|
|
1210
|
+
disabled: 1,
|
|
1211
|
+
hidden: 1,
|
|
1212
|
+
inert: 1,
|
|
1213
|
+
loop: 1,
|
|
1214
|
+
open: 1,
|
|
1215
|
+
required: 1,
|
|
1216
|
+
reversed: 1,
|
|
1217
|
+
scoped: 1,
|
|
1218
|
+
seamless: 1,
|
|
1219
|
+
checked: 1,
|
|
1220
|
+
muted: 1,
|
|
1221
|
+
multiple: 1,
|
|
1222
|
+
selected: 1
|
|
1223
|
+
};
|
|
1224
|
+
var updateAttr = (el, values, previousValues, option, previousOption, flags) => {
|
|
1225
|
+
if (option) {
|
|
1226
|
+
option = unref(option);
|
|
1227
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
1228
|
+
patchAttr(
|
|
1229
|
+
el,
|
|
1230
|
+
option,
|
|
1231
|
+
unref(values[0]),
|
|
1232
|
+
unref(previousOption)
|
|
1233
|
+
);
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
const len = values.length;
|
|
1237
|
+
for (let i = 0; i < len; ++i) {
|
|
1238
|
+
const next = values[i];
|
|
1239
|
+
if (isArray(next)) {
|
|
1240
|
+
const previousKey = unref(previousValues?.[i]?.[0]);
|
|
1241
|
+
const key = unref(next[0]);
|
|
1242
|
+
const value = unref(next[1]);
|
|
1243
|
+
patchAttr(el, key, value, previousKey);
|
|
1244
|
+
} else if (isObject(next)) {
|
|
1245
|
+
for (const item of Object.entries(next)) {
|
|
1246
|
+
const key = item[0];
|
|
1247
|
+
const value = unref(item[1]);
|
|
1248
|
+
const p = unref(previousValues?.[i]);
|
|
1249
|
+
const previousKey = p && key in p ? key : void 0;
|
|
1250
|
+
patchAttr(el, key, value, previousKey);
|
|
1251
|
+
}
|
|
1252
|
+
} else {
|
|
1253
|
+
const previousKey = unref(previousValues?.[i]);
|
|
1254
|
+
const key = unref(values[i++]);
|
|
1255
|
+
const value = unref(values[i]);
|
|
1256
|
+
patchAttr(el, key, value, previousKey);
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
};
|
|
1260
|
+
var attrDirective = {
|
|
1261
|
+
mount: () => ({
|
|
1262
|
+
update: ({ el, values, previousValues, option, previousOption, flags }) => {
|
|
1263
|
+
updateAttr(
|
|
1264
|
+
el,
|
|
1265
|
+
values,
|
|
1266
|
+
previousValues,
|
|
1267
|
+
option,
|
|
1268
|
+
previousOption,
|
|
1269
|
+
flags
|
|
1270
|
+
);
|
|
1271
|
+
}
|
|
1272
|
+
})
|
|
1273
|
+
};
|
|
1274
|
+
var patchAttr = (el, key, value, previousKey) => {
|
|
1275
|
+
if (previousKey && previousKey !== key) {
|
|
1276
|
+
el.removeAttribute(previousKey);
|
|
1277
|
+
}
|
|
1278
|
+
if (isNullOrUndefined(key)) {
|
|
1279
|
+
warning(3 /* KeyIsEmpty */, "r-bind", el);
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
if (!isString(key)) {
|
|
1283
|
+
warning(
|
|
1284
|
+
6 /* ErrorLog */,
|
|
1285
|
+
`Attribute key is not string at ${el.outerHTML}`,
|
|
1286
|
+
key
|
|
1287
|
+
);
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
if (key.startsWith("xlink:")) {
|
|
1291
|
+
if (isNullOrUndefined(value)) {
|
|
1292
|
+
el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
|
1293
|
+
} else {
|
|
1294
|
+
el.setAttributeNS(xlinkNS, key, value);
|
|
1295
|
+
}
|
|
1296
|
+
return;
|
|
1297
|
+
}
|
|
1298
|
+
if (isNullOrUndefined(value)) {
|
|
1299
|
+
el.removeAttribute(key);
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
if (key in booleanAttributes) {
|
|
1303
|
+
if (toBoolean(value)) {
|
|
1304
|
+
el.setAttribute(key, "");
|
|
1305
|
+
} else {
|
|
1306
|
+
el.removeAttribute(key);
|
|
1307
|
+
}
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
el.setAttribute(key, value);
|
|
1311
|
+
};
|
|
1312
|
+
|
|
1188
1313
|
// src/directives/context.ts
|
|
1189
1314
|
var contextDirective = {
|
|
1190
1315
|
collectRefObj: true,
|
|
@@ -1915,10 +2040,11 @@ var Regor = (() => {
|
|
|
1915
2040
|
} else if (attrName === ":style" || attrName === bindStyleName) {
|
|
1916
2041
|
mergeBinding(":style", bindStyleName, value);
|
|
1917
2042
|
} else {
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
2043
|
+
const normalizedName = normalizeAttributeName(
|
|
2044
|
+
attrName,
|
|
2045
|
+
binder.__config
|
|
1921
2046
|
);
|
|
2047
|
+
patchAttr(inheritor, normalizedName, value);
|
|
1922
2048
|
}
|
|
1923
2049
|
};
|
|
1924
2050
|
for (const { name, value } of inheritedPropAttrs) {
|
|
@@ -2254,12 +2380,6 @@ var Regor = (() => {
|
|
|
2254
2380
|
}
|
|
2255
2381
|
};
|
|
2256
2382
|
|
|
2257
|
-
// src/reactivity/unref.ts
|
|
2258
|
-
var unref = (value) => {
|
|
2259
|
-
const anyValue = value;
|
|
2260
|
-
return anyValue != null && anyValue[srefSymbol] > 0 ? anyValue() : anyValue;
|
|
2261
|
-
};
|
|
2262
|
-
|
|
2263
2383
|
// src/directives/html.ts
|
|
2264
2384
|
var updateHtml = (el, values) => {
|
|
2265
2385
|
const [value, replacer] = values;
|
|
@@ -3195,115 +3315,6 @@ var Regor = (() => {
|
|
|
3195
3315
|
}
|
|
3196
3316
|
};
|
|
3197
3317
|
|
|
3198
|
-
// src/directives/attr.ts
|
|
3199
|
-
var xlinkNS = "http://www.w3.org/1999/xlink";
|
|
3200
|
-
var booleanAttributes = {
|
|
3201
|
-
itemscope: 2,
|
|
3202
|
-
allowfullscreen: 2,
|
|
3203
|
-
formnovalidate: 2,
|
|
3204
|
-
ismap: 2,
|
|
3205
|
-
nomodule: 2,
|
|
3206
|
-
novalidate: 2,
|
|
3207
|
-
readonly: 2,
|
|
3208
|
-
async: 1,
|
|
3209
|
-
autofocus: 1,
|
|
3210
|
-
autoplay: 1,
|
|
3211
|
-
controls: 1,
|
|
3212
|
-
default: 1,
|
|
3213
|
-
defer: 1,
|
|
3214
|
-
disabled: 1,
|
|
3215
|
-
hidden: 1,
|
|
3216
|
-
inert: 1,
|
|
3217
|
-
loop: 1,
|
|
3218
|
-
open: 1,
|
|
3219
|
-
required: 1,
|
|
3220
|
-
reversed: 1,
|
|
3221
|
-
scoped: 1,
|
|
3222
|
-
seamless: 1,
|
|
3223
|
-
checked: 1,
|
|
3224
|
-
muted: 1,
|
|
3225
|
-
multiple: 1,
|
|
3226
|
-
selected: 1
|
|
3227
|
-
};
|
|
3228
|
-
function includeBooleanAttr(value) {
|
|
3229
|
-
return !!value || value === "";
|
|
3230
|
-
}
|
|
3231
|
-
var updateAttr = (el, values, previousValues, option, previousOption, flags) => {
|
|
3232
|
-
if (option) {
|
|
3233
|
-
if (flags && flags.includes("camel")) option = camelize(option);
|
|
3234
|
-
patchAttribute(el, option, values[0], previousOption);
|
|
3235
|
-
return;
|
|
3236
|
-
}
|
|
3237
|
-
const len = values.length;
|
|
3238
|
-
for (let i = 0; i < len; ++i) {
|
|
3239
|
-
const next = values[i];
|
|
3240
|
-
if (isArray(next)) {
|
|
3241
|
-
const previousKey = previousValues?.[i]?.[0];
|
|
3242
|
-
const key = next[0];
|
|
3243
|
-
const value = next[1];
|
|
3244
|
-
patchAttribute(el, key, value, previousKey);
|
|
3245
|
-
} else if (isObject(next)) {
|
|
3246
|
-
for (const item of Object.entries(next)) {
|
|
3247
|
-
const key = item[0];
|
|
3248
|
-
const value = item[1];
|
|
3249
|
-
const p = previousValues?.[i];
|
|
3250
|
-
const previousKey = p && key in p ? key : void 0;
|
|
3251
|
-
patchAttribute(el, key, value, previousKey);
|
|
3252
|
-
}
|
|
3253
|
-
} else {
|
|
3254
|
-
const previousKey = previousValues?.[i];
|
|
3255
|
-
const key = values[i++];
|
|
3256
|
-
const value = values[i];
|
|
3257
|
-
patchAttribute(el, key, value, previousKey);
|
|
3258
|
-
}
|
|
3259
|
-
}
|
|
3260
|
-
};
|
|
3261
|
-
var attrDirective = {
|
|
3262
|
-
mount: () => ({
|
|
3263
|
-
update: ({ el, values, previousValues, option, previousOption, flags }) => {
|
|
3264
|
-
updateAttr(
|
|
3265
|
-
el,
|
|
3266
|
-
values,
|
|
3267
|
-
previousValues,
|
|
3268
|
-
option,
|
|
3269
|
-
previousOption,
|
|
3270
|
-
flags
|
|
3271
|
-
);
|
|
3272
|
-
}
|
|
3273
|
-
})
|
|
3274
|
-
};
|
|
3275
|
-
var patchAttribute = (el, key, value, previousKey) => {
|
|
3276
|
-
if (previousKey && previousKey !== key) {
|
|
3277
|
-
el.removeAttribute(previousKey);
|
|
3278
|
-
}
|
|
3279
|
-
if (isNullOrUndefined(key)) {
|
|
3280
|
-
warning(3 /* KeyIsEmpty */, "r-bind", el);
|
|
3281
|
-
return;
|
|
3282
|
-
}
|
|
3283
|
-
if (!isString(key)) {
|
|
3284
|
-
warning(
|
|
3285
|
-
6 /* ErrorLog */,
|
|
3286
|
-
`Attribute key is not string at ${el.outerHTML}`,
|
|
3287
|
-
key
|
|
3288
|
-
);
|
|
3289
|
-
return;
|
|
3290
|
-
}
|
|
3291
|
-
if (key.startsWith("xlink:")) {
|
|
3292
|
-
if (isNullOrUndefined(value)) {
|
|
3293
|
-
el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
|
3294
|
-
} else {
|
|
3295
|
-
el.setAttributeNS(xlinkNS, key, value);
|
|
3296
|
-
}
|
|
3297
|
-
return;
|
|
3298
|
-
}
|
|
3299
|
-
const isBoolean2 = key in booleanAttributes;
|
|
3300
|
-
if (isNullOrUndefined(value) || isBoolean2 && !includeBooleanAttr(value)) {
|
|
3301
|
-
el.removeAttribute(key);
|
|
3302
|
-
} else {
|
|
3303
|
-
el.setAttribute(key, isBoolean2 ? "" : value);
|
|
3304
|
-
}
|
|
3305
|
-
};
|
|
3306
|
-
|
|
3307
3318
|
// src/directives/class.ts
|
|
3308
3319
|
var updateClass = (el, values, previousValues) => {
|
|
3309
3320
|
const len = values.length;
|
|
@@ -3685,8 +3696,10 @@ var Regor = (() => {
|
|
|
3685
3696
|
};
|
|
3686
3697
|
var handleSelect = (el, getModelRef, parsedValue) => {
|
|
3687
3698
|
const eventType = "change";
|
|
3699
|
+
const stopObservingOptions = observeSelectOptions(el, parsedValue);
|
|
3688
3700
|
const unbinder = () => {
|
|
3689
3701
|
el.removeEventListener(eventType, listener);
|
|
3702
|
+
stopObservingOptions();
|
|
3690
3703
|
};
|
|
3691
3704
|
const listener = () => {
|
|
3692
3705
|
const modelRef = getModelRef();
|
|
@@ -3720,6 +3733,35 @@ var Regor = (() => {
|
|
|
3720
3733
|
el.addEventListener(eventType, listener);
|
|
3721
3734
|
return unbinder;
|
|
3722
3735
|
};
|
|
3736
|
+
var observeSelectOptions = (el, parsedValue) => {
|
|
3737
|
+
const MutationObserverCtor = globalThis.MutationObserver ?? globalThis.window?.MutationObserver;
|
|
3738
|
+
if (!MutationObserverCtor) return () => {
|
|
3739
|
+
};
|
|
3740
|
+
let pending = false;
|
|
3741
|
+
let stopped = false;
|
|
3742
|
+
const flush = () => {
|
|
3743
|
+
pending = false;
|
|
3744
|
+
if (stopped) return;
|
|
3745
|
+
updateDomElementValue(el, parsedValue()[0]);
|
|
3746
|
+
};
|
|
3747
|
+
const scheduleFlush = () => {
|
|
3748
|
+
if (pending) return;
|
|
3749
|
+
pending = true;
|
|
3750
|
+
if (typeof queueMicrotask === "function") queueMicrotask(flush);
|
|
3751
|
+
else Promise.resolve().then(flush);
|
|
3752
|
+
};
|
|
3753
|
+
const observer = new MutationObserverCtor(scheduleFlush);
|
|
3754
|
+
observer.observe(el, {
|
|
3755
|
+
attributes: true,
|
|
3756
|
+
attributeFilter: ["value"],
|
|
3757
|
+
childList: true,
|
|
3758
|
+
subtree: true
|
|
3759
|
+
});
|
|
3760
|
+
return () => {
|
|
3761
|
+
stopped = true;
|
|
3762
|
+
observer.disconnect();
|
|
3763
|
+
};
|
|
3764
|
+
};
|
|
3723
3765
|
|
|
3724
3766
|
// src/directives/on.ts
|
|
3725
3767
|
var availableFlags = [
|
|
@@ -3917,7 +3959,7 @@ var Regor = (() => {
|
|
|
3917
3959
|
}
|
|
3918
3960
|
})
|
|
3919
3961
|
};
|
|
3920
|
-
function
|
|
3962
|
+
function includeBooleanAttr(value) {
|
|
3921
3963
|
return !!value || value === "";
|
|
3922
3964
|
}
|
|
3923
3965
|
var patchProp = (el, key, value) => {
|
|
@@ -3949,7 +3991,7 @@ var Regor = (() => {
|
|
|
3949
3991
|
if (value === "" || value == null) {
|
|
3950
3992
|
const type = typeof el[key];
|
|
3951
3993
|
if (type === "boolean") {
|
|
3952
|
-
value =
|
|
3994
|
+
value = includeBooleanAttr(value);
|
|
3953
3995
|
} else if (value == null && type === "string") {
|
|
3954
3996
|
value = "";
|
|
3955
3997
|
needRemove = true;
|