@schukai/monster 4.148.7 → 4.148.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/package.json +1 -1
- package/source/components/form/control-bar.mjs +212 -177
- package/source/dom/customelement.mjs +105 -40
- package/source/dom/updater.mjs +381 -119
- package/test/cases/components/form/control-bar.mjs +218 -10
- package/test/cases/dom/customelement.mjs +136 -1
- package/test/cases/dom/updater.mjs +174 -0
|
@@ -122,6 +122,20 @@ const managedShadowRootSymbol = Symbol("managedShadowRoot");
|
|
|
122
122
|
const visibilityStateSymbol = Symbol("visibilityState");
|
|
123
123
|
let hostVisibilityStyleSheet = null;
|
|
124
124
|
|
|
125
|
+
class RevisionObserver extends Observer {
|
|
126
|
+
#onNotification;
|
|
127
|
+
|
|
128
|
+
constructor(callback, onNotification) {
|
|
129
|
+
super(callback);
|
|
130
|
+
this.#onNotification = onNotification;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
update(subject) {
|
|
134
|
+
this.#onNotification();
|
|
135
|
+
return super.update(subject);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
125
139
|
/**
|
|
126
140
|
* The `CustomElement` class provides a way to define a new HTML element using the power of Custom Elements.
|
|
127
141
|
*
|
|
@@ -1207,20 +1221,42 @@ function initOptionObserver() {
|
|
|
1207
1221
|
|
|
1208
1222
|
self[internalSymbol].syncDisabledState = syncDisabledState;
|
|
1209
1223
|
|
|
1224
|
+
let updaterSyncRevision = 0;
|
|
1210
1225
|
self.attachObserver(
|
|
1211
|
-
new
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1226
|
+
new RevisionObserver(
|
|
1227
|
+
async function () {
|
|
1228
|
+
let processedRevision;
|
|
1229
|
+
do {
|
|
1230
|
+
processedRevision = updaterSyncRevision;
|
|
1231
|
+
if (hasObjectLink(self, customElementUpdaterLinkSymbol)) {
|
|
1232
|
+
const source = clone(
|
|
1233
|
+
self[internalSymbol].getRealSubject()["options"],
|
|
1234
|
+
);
|
|
1235
|
+
const notifications = [];
|
|
1236
|
+
const updaters = getLinkedObjects(
|
|
1237
|
+
self,
|
|
1238
|
+
customElementUpdaterLinkSymbol,
|
|
1239
|
+
);
|
|
1240
|
+
|
|
1241
|
+
for (const list of updaters) {
|
|
1242
|
+
for (const updater of list) {
|
|
1243
|
+
syncUpdaterSubject(updater.getSubject(), source);
|
|
1244
|
+
const subject = updater?.[internalSymbol]?.subject;
|
|
1245
|
+
if (subject instanceof ProxyObserver) {
|
|
1246
|
+
notifications.push(subject.notifyObservers());
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
await Promise.all(notifications);
|
|
1251
|
+
}
|
|
1216
1252
|
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1253
|
+
await Promise.resolve();
|
|
1254
|
+
} while (processedRevision !== updaterSyncRevision);
|
|
1255
|
+
},
|
|
1256
|
+
() => {
|
|
1257
|
+
updaterSyncRevision++;
|
|
1258
|
+
},
|
|
1259
|
+
),
|
|
1224
1260
|
);
|
|
1225
1261
|
|
|
1226
1262
|
self[attributeObserverSymbol][ATTRIBUTE_DISABLED] = () => {
|
|
@@ -1258,39 +1294,68 @@ function syncUpdaterSubject(target, source) {
|
|
|
1258
1294
|
}
|
|
1259
1295
|
|
|
1260
1296
|
for (const [key, value] of Object.entries(source)) {
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
(typeof DocumentFragment !== "undefined" &&
|
|
1265
|
-
value instanceof DocumentFragment)
|
|
1266
|
-
) {
|
|
1267
|
-
target[key] = value;
|
|
1268
|
-
continue;
|
|
1269
|
-
}
|
|
1297
|
+
syncUpdaterValue(target, key, value);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1270
1300
|
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1301
|
+
/**
|
|
1302
|
+
* Synchronizes an updater value while preserving proxied array and plain-object
|
|
1303
|
+
* identities. Equal primitive entries therefore do not notify observers again.
|
|
1304
|
+
* @private
|
|
1305
|
+
* @param {object|array} target
|
|
1306
|
+
* @param {string|number} key
|
|
1307
|
+
* @param {*} value
|
|
1308
|
+
* @return {void}
|
|
1309
|
+
*/
|
|
1310
|
+
function syncUpdaterValue(target, key, value) {
|
|
1311
|
+
if (
|
|
1312
|
+
isElement(value) ||
|
|
1313
|
+
(typeof Document !== "undefined" && value instanceof Document) ||
|
|
1314
|
+
(typeof DocumentFragment !== "undefined" &&
|
|
1315
|
+
value instanceof DocumentFragment)
|
|
1316
|
+
) {
|
|
1317
|
+
target[key] = value;
|
|
1318
|
+
return;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
if (isArray(value)) {
|
|
1322
|
+
if (!isArray(target?.[key])) {
|
|
1323
|
+
target[key] = clone(value);
|
|
1324
|
+
return;
|
|
1278
1325
|
}
|
|
1326
|
+
syncUpdaterArray(target[key], value);
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
1279
1329
|
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
}
|
|
1286
|
-
if (!isObject(target?.[key]) || isArray(target?.[key])) {
|
|
1287
|
-
target[key] = {};
|
|
1288
|
-
}
|
|
1289
|
-
syncUpdaterSubject(target[key], value);
|
|
1290
|
-
continue;
|
|
1330
|
+
if (isObject(value)) {
|
|
1331
|
+
const proto = Object.getPrototypeOf(value);
|
|
1332
|
+
if (proto && proto !== Object.prototype) {
|
|
1333
|
+
target[key] = value;
|
|
1334
|
+
return;
|
|
1291
1335
|
}
|
|
1336
|
+
if (!isObject(target?.[key]) || isArray(target?.[key])) {
|
|
1337
|
+
target[key] = {};
|
|
1338
|
+
}
|
|
1339
|
+
syncUpdaterSubject(target[key], value);
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1292
1342
|
|
|
1293
|
-
|
|
1343
|
+
target[key] = value;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
/**
|
|
1347
|
+
* @private
|
|
1348
|
+
* @param {array} target
|
|
1349
|
+
* @param {array} source
|
|
1350
|
+
* @return {void}
|
|
1351
|
+
*/
|
|
1352
|
+
function syncUpdaterArray(target, source) {
|
|
1353
|
+
for (let index = 0; index < source.length; index++) {
|
|
1354
|
+
syncUpdaterValue(target, index, source[index]);
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
if (target.length !== source.length) {
|
|
1358
|
+
target.length = source.length;
|
|
1294
1359
|
}
|
|
1295
1360
|
}
|
|
1296
1361
|
|