regor 1.7.0 → 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.
@@ -1193,6 +1193,132 @@ var isScope = (value) => {
1193
1193
  return scopeSymbol2 in value;
1194
1194
  };
1195
1195
 
1196
+ // src/reactivity/unref.ts
1197
+ var unref = (value) => {
1198
+ const anyValue = value;
1199
+ return anyValue != null && anyValue[srefSymbol] > 0 ? anyValue() : anyValue;
1200
+ };
1201
+
1202
+ // src/directives/attr.ts
1203
+ var xlinkNS = "http://www.w3.org/1999/xlink";
1204
+ var booleanAttributes = {
1205
+ itemscope: 2,
1206
+ allowfullscreen: 2,
1207
+ formnovalidate: 2,
1208
+ ismap: 2,
1209
+ nomodule: 2,
1210
+ novalidate: 2,
1211
+ readonly: 2,
1212
+ async: 1,
1213
+ autofocus: 1,
1214
+ autoplay: 1,
1215
+ controls: 1,
1216
+ default: 1,
1217
+ defer: 1,
1218
+ disabled: 1,
1219
+ hidden: 1,
1220
+ inert: 1,
1221
+ loop: 1,
1222
+ open: 1,
1223
+ required: 1,
1224
+ reversed: 1,
1225
+ scoped: 1,
1226
+ seamless: 1,
1227
+ checked: 1,
1228
+ muted: 1,
1229
+ multiple: 1,
1230
+ selected: 1
1231
+ };
1232
+ var updateAttr = (el, values, previousValues, option, previousOption, flags) => {
1233
+ var _a;
1234
+ if (option) {
1235
+ option = unref(option);
1236
+ if (flags && flags.includes("camel")) option = camelize(option);
1237
+ patchAttr(
1238
+ el,
1239
+ option,
1240
+ unref(values[0]),
1241
+ unref(previousOption)
1242
+ );
1243
+ return;
1244
+ }
1245
+ const len = values.length;
1246
+ for (let i = 0; i < len; ++i) {
1247
+ const next = values[i];
1248
+ if (isArray(next)) {
1249
+ const previousKey = unref((_a = previousValues == null ? void 0 : previousValues[i]) == null ? void 0 : _a[0]);
1250
+ const key = unref(next[0]);
1251
+ const value = unref(next[1]);
1252
+ patchAttr(el, key, value, previousKey);
1253
+ } else if (isObject(next)) {
1254
+ for (const item of Object.entries(next)) {
1255
+ const key = item[0];
1256
+ const value = unref(item[1]);
1257
+ const p = unref(previousValues == null ? void 0 : previousValues[i]);
1258
+ const previousKey = p && key in p ? key : void 0;
1259
+ patchAttr(el, key, value, previousKey);
1260
+ }
1261
+ } else {
1262
+ const previousKey = unref(previousValues == null ? void 0 : previousValues[i]);
1263
+ const key = unref(values[i++]);
1264
+ const value = unref(values[i]);
1265
+ patchAttr(el, key, value, previousKey);
1266
+ }
1267
+ }
1268
+ };
1269
+ var attrDirective = {
1270
+ mount: () => ({
1271
+ update: ({ el, values, previousValues, option, previousOption, flags }) => {
1272
+ updateAttr(
1273
+ el,
1274
+ values,
1275
+ previousValues,
1276
+ option,
1277
+ previousOption,
1278
+ flags
1279
+ );
1280
+ }
1281
+ })
1282
+ };
1283
+ var patchAttr = (el, key, value, previousKey) => {
1284
+ if (previousKey && previousKey !== key) {
1285
+ el.removeAttribute(previousKey);
1286
+ }
1287
+ if (isNullOrUndefined(key)) {
1288
+ warning(3 /* KeyIsEmpty */, "r-bind", el);
1289
+ return;
1290
+ }
1291
+ if (!isString(key)) {
1292
+ warning(
1293
+ 6 /* ErrorLog */,
1294
+ `Attribute key is not string at ${el.outerHTML}`,
1295
+ key
1296
+ );
1297
+ return;
1298
+ }
1299
+ if (key.startsWith("xlink:")) {
1300
+ if (isNullOrUndefined(value)) {
1301
+ el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
1302
+ } else {
1303
+ el.setAttributeNS(xlinkNS, key, value);
1304
+ }
1305
+ return;
1306
+ }
1307
+ if (isNullOrUndefined(value)) {
1308
+ el.removeAttribute(key);
1309
+ return;
1310
+ }
1311
+ if (key in booleanAttributes) {
1312
+ if (toBoolean(value)) {
1313
+ el.setAttribute(key, "");
1314
+ } else {
1315
+ el.removeAttribute(key);
1316
+ }
1317
+ return;
1318
+ }
1319
+ el.setAttribute(key, value);
1320
+ };
1321
+
1196
1322
  // src/directives/context.ts
1197
1323
  var contextDirective = {
1198
1324
  collectRefObj: true,
@@ -1931,10 +2057,11 @@ var ComponentBinder = class {
1931
2057
  } else if (attrName === ":style" || attrName === bindStyleName) {
1932
2058
  mergeBinding(":style", bindStyleName, value);
1933
2059
  } else {
1934
- inheritor.setAttribute(
1935
- normalizeAttributeName(attrName, binder.__config),
1936
- value
2060
+ const normalizedName = normalizeAttributeName(
2061
+ attrName,
2062
+ binder.__config
1937
2063
  );
2064
+ patchAttr(inheritor, normalizedName, value);
1938
2065
  }
1939
2066
  };
1940
2067
  for (const { name, value } of inheritedPropAttrs) {
@@ -2276,12 +2403,6 @@ var DynamicBinder = class {
2276
2403
  }
2277
2404
  };
2278
2405
 
2279
- // src/reactivity/unref.ts
2280
- var unref = (value) => {
2281
- const anyValue = value;
2282
- return anyValue != null && anyValue[srefSymbol] > 0 ? anyValue() : anyValue;
2283
- };
2284
-
2285
2406
  // src/directives/html.ts
2286
2407
  var updateHtml = (el, values) => {
2287
2408
  const [value, replacer] = values;
@@ -3231,116 +3352,6 @@ var Binder = class {
3231
3352
  }
3232
3353
  };
3233
3354
 
3234
- // src/directives/attr.ts
3235
- var xlinkNS = "http://www.w3.org/1999/xlink";
3236
- var booleanAttributes = {
3237
- itemscope: 2,
3238
- allowfullscreen: 2,
3239
- formnovalidate: 2,
3240
- ismap: 2,
3241
- nomodule: 2,
3242
- novalidate: 2,
3243
- readonly: 2,
3244
- async: 1,
3245
- autofocus: 1,
3246
- autoplay: 1,
3247
- controls: 1,
3248
- default: 1,
3249
- defer: 1,
3250
- disabled: 1,
3251
- hidden: 1,
3252
- inert: 1,
3253
- loop: 1,
3254
- open: 1,
3255
- required: 1,
3256
- reversed: 1,
3257
- scoped: 1,
3258
- seamless: 1,
3259
- checked: 1,
3260
- muted: 1,
3261
- multiple: 1,
3262
- selected: 1
3263
- };
3264
- function includeBooleanAttr(value) {
3265
- return !!value || value === "";
3266
- }
3267
- var updateAttr = (el, values, previousValues, option, previousOption, flags) => {
3268
- var _a;
3269
- if (option) {
3270
- if (flags && flags.includes("camel")) option = camelize(option);
3271
- patchAttribute(el, option, values[0], previousOption);
3272
- return;
3273
- }
3274
- const len = values.length;
3275
- for (let i = 0; i < len; ++i) {
3276
- const next = values[i];
3277
- if (isArray(next)) {
3278
- const previousKey = (_a = previousValues == null ? void 0 : previousValues[i]) == null ? void 0 : _a[0];
3279
- const key = next[0];
3280
- const value = next[1];
3281
- patchAttribute(el, key, value, previousKey);
3282
- } else if (isObject(next)) {
3283
- for (const item of Object.entries(next)) {
3284
- const key = item[0];
3285
- const value = item[1];
3286
- const p = previousValues == null ? void 0 : previousValues[i];
3287
- const previousKey = p && key in p ? key : void 0;
3288
- patchAttribute(el, key, value, previousKey);
3289
- }
3290
- } else {
3291
- const previousKey = previousValues == null ? void 0 : previousValues[i];
3292
- const key = values[i++];
3293
- const value = values[i];
3294
- patchAttribute(el, key, value, previousKey);
3295
- }
3296
- }
3297
- };
3298
- var attrDirective = {
3299
- mount: () => ({
3300
- update: ({ el, values, previousValues, option, previousOption, flags }) => {
3301
- updateAttr(
3302
- el,
3303
- values,
3304
- previousValues,
3305
- option,
3306
- previousOption,
3307
- flags
3308
- );
3309
- }
3310
- })
3311
- };
3312
- var patchAttribute = (el, key, value, previousKey) => {
3313
- if (previousKey && previousKey !== key) {
3314
- el.removeAttribute(previousKey);
3315
- }
3316
- if (isNullOrUndefined(key)) {
3317
- warning(3 /* KeyIsEmpty */, "r-bind", el);
3318
- return;
3319
- }
3320
- if (!isString(key)) {
3321
- warning(
3322
- 6 /* ErrorLog */,
3323
- `Attribute key is not string at ${el.outerHTML}`,
3324
- key
3325
- );
3326
- return;
3327
- }
3328
- if (key.startsWith("xlink:")) {
3329
- if (isNullOrUndefined(value)) {
3330
- el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
3331
- } else {
3332
- el.setAttributeNS(xlinkNS, key, value);
3333
- }
3334
- return;
3335
- }
3336
- const isBoolean2 = key in booleanAttributes;
3337
- if (isNullOrUndefined(value) || isBoolean2 && !includeBooleanAttr(value)) {
3338
- el.removeAttribute(key);
3339
- } else {
3340
- el.setAttribute(key, isBoolean2 ? "" : value);
3341
- }
3342
- };
3343
-
3344
3355
  // src/directives/class.ts
3345
3356
  var updateClass = (el, values, previousValues) => {
3346
3357
  const len = values.length;
@@ -3987,7 +3998,7 @@ var propDirective = {
3987
3998
  }
3988
3999
  })
3989
4000
  };
3990
- function includeBooleanAttr2(value) {
4001
+ function includeBooleanAttr(value) {
3991
4002
  return !!value || value === "";
3992
4003
  }
3993
4004
  var patchProp = (el, key, value) => {
@@ -4019,7 +4030,7 @@ var patchProp = (el, key, value) => {
4019
4030
  if (value === "" || value == null) {
4020
4031
  const type = typeof el[key];
4021
4032
  if (type === "boolean") {
4022
- value = includeBooleanAttr2(value);
4033
+ value = includeBooleanAttr(value);
4023
4034
  } else if (value == null && type === "string") {
4024
4035
  value = "";
4025
4036
  needRemove = true;