@manyducks.co/dolla 0.75.0 → 0.76.0
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/lib/index.js +47 -33
- package/lib/index.js.map +2 -2
- package/lib/nodes/html.d.ts +1 -1
- package/lib/stores/router.d.ts +5 -1
- package/notes/views.md +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1070,16 +1070,21 @@ var HTML = class {
|
|
|
1070
1070
|
const propStopCallbacks = [];
|
|
1071
1071
|
if (styles == void 0) {
|
|
1072
1072
|
element.style.cssText = "";
|
|
1073
|
+
} else if (typeof styles === "string") {
|
|
1074
|
+
element.style.cssText = styles;
|
|
1073
1075
|
} else if (isReadable(styles)) {
|
|
1074
1076
|
let unapply;
|
|
1075
1077
|
const stop = observe(styles, (current) => {
|
|
1076
|
-
render.update(
|
|
1077
|
-
|
|
1078
|
-
unapply
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1078
|
+
render.update(
|
|
1079
|
+
() => {
|
|
1080
|
+
if (isFunction(unapply)) {
|
|
1081
|
+
unapply();
|
|
1082
|
+
}
|
|
1083
|
+
element.style.cssText = "";
|
|
1084
|
+
unapply = this.applyStyles(element, current, stopCallbacks);
|
|
1085
|
+
},
|
|
1086
|
+
this.getUpdateKey("styles", "*")
|
|
1087
|
+
);
|
|
1083
1088
|
});
|
|
1084
1089
|
stopCallbacks.push(stop);
|
|
1085
1090
|
propStopCallbacks.push(stop);
|
|
@@ -1090,13 +1095,16 @@ var HTML = class {
|
|
|
1090
1095
|
const setProperty = key.startsWith("--") ? (key2, value2) => value2 == null ? element.style.removeProperty(key2) : element.style.setProperty(key2, value2) : (key2, value2) => element.style[key2] = value2 ?? "";
|
|
1091
1096
|
if (isReadable(value)) {
|
|
1092
1097
|
const stop = observe(value, (current) => {
|
|
1093
|
-
render.update(
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1098
|
+
render.update(
|
|
1099
|
+
() => {
|
|
1100
|
+
if (current != null) {
|
|
1101
|
+
setProperty(key, current);
|
|
1102
|
+
} else {
|
|
1103
|
+
element.style.removeProperty(key);
|
|
1104
|
+
}
|
|
1105
|
+
},
|
|
1106
|
+
this.getUpdateKey("style", key)
|
|
1107
|
+
);
|
|
1100
1108
|
});
|
|
1101
1109
|
stopCallbacks.push(stop);
|
|
1102
1110
|
propStopCallbacks.push(stop);
|
|
@@ -1124,13 +1132,16 @@ var HTML = class {
|
|
|
1124
1132
|
if (isReadable(classes)) {
|
|
1125
1133
|
let unapply;
|
|
1126
1134
|
const stop = observe(classes, (current) => {
|
|
1127
|
-
render.update(
|
|
1128
|
-
|
|
1129
|
-
unapply
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1135
|
+
render.update(
|
|
1136
|
+
() => {
|
|
1137
|
+
if (isFunction(unapply)) {
|
|
1138
|
+
unapply();
|
|
1139
|
+
}
|
|
1140
|
+
element.removeAttribute("class");
|
|
1141
|
+
unapply = this.applyClasses(element, current, stopCallbacks);
|
|
1142
|
+
},
|
|
1143
|
+
this.getUpdateKey("attr", "class")
|
|
1144
|
+
);
|
|
1134
1145
|
});
|
|
1135
1146
|
stopCallbacks.push(stop);
|
|
1136
1147
|
classStopCallbacks.push(stop);
|
|
@@ -2984,6 +2995,9 @@ function resolvePath(base, part) {
|
|
|
2984
2995
|
function parseQueryParams(query) {
|
|
2985
2996
|
if (!query)
|
|
2986
2997
|
return {};
|
|
2998
|
+
if (query.startsWith("?")) {
|
|
2999
|
+
query = query.slice(1);
|
|
3000
|
+
}
|
|
2987
3001
|
const entries = query.split("&").filter((x) => x.trim() !== "").map((entry) => {
|
|
2988
3002
|
const [key, value] = entry.split("=").map((x) => x.trim());
|
|
2989
3003
|
if (value.toLowerCase() === "true") {
|
|
@@ -3241,21 +3255,19 @@ function RouterStore(ctx) {
|
|
|
3241
3255
|
const $$pattern = $$(null);
|
|
3242
3256
|
const $$path = $$("");
|
|
3243
3257
|
const $$params = $$({});
|
|
3244
|
-
const $$query = $$(
|
|
3245
|
-
let isRouteChange = true;
|
|
3258
|
+
const $$query = $$(parseQueryParams(window.location.search));
|
|
3246
3259
|
ctx.observe($$query, (current) => {
|
|
3247
|
-
if (isRouteChange) {
|
|
3248
|
-
isRouteChange = false;
|
|
3249
|
-
return;
|
|
3250
|
-
}
|
|
3251
3260
|
const params = new URLSearchParams();
|
|
3252
3261
|
for (const key in current) {
|
|
3253
3262
|
params.set(key, String(current[key]));
|
|
3254
3263
|
}
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3264
|
+
const search = "?" + params.toString();
|
|
3265
|
+
if (search != history.location.search) {
|
|
3266
|
+
history.replace({
|
|
3267
|
+
pathname: history.location.pathname,
|
|
3268
|
+
search
|
|
3269
|
+
});
|
|
3270
|
+
}
|
|
3259
3271
|
});
|
|
3260
3272
|
ctx.onConnected(() => {
|
|
3261
3273
|
history.listen(onRouteChange);
|
|
@@ -3275,8 +3287,7 @@ function RouterStore(ctx) {
|
|
|
3275
3287
|
const onRouteChange = async ({ location }) => {
|
|
3276
3288
|
if (location.search !== lastQuery) {
|
|
3277
3289
|
lastQuery = location.search;
|
|
3278
|
-
|
|
3279
|
-
$$query.set(parseQueryParams(location.search.startsWith("?") ? location.search.slice(1) : location.search));
|
|
3290
|
+
$$query.set(parseQueryParams(location.search));
|
|
3280
3291
|
}
|
|
3281
3292
|
const matched = matchRoutes(routes, location.pathname);
|
|
3282
3293
|
if (!matched) {
|
|
@@ -3388,6 +3399,9 @@ function RouterStore(ctx) {
|
|
|
3388
3399
|
joined = path.toString();
|
|
3389
3400
|
}
|
|
3390
3401
|
joined = resolvePath(history.location.pathname, joined);
|
|
3402
|
+
if (options.preserveQuery) {
|
|
3403
|
+
joined += history.location.search;
|
|
3404
|
+
}
|
|
3391
3405
|
if (options.replace) {
|
|
3392
3406
|
history.replace(joined);
|
|
3393
3407
|
} else {
|