dalila 1.5.7 → 1.5.8
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/runtime/bind.js +18 -4
- package/package.json +1 -1
package/dist/runtime/bind.js
CHANGED
|
@@ -189,7 +189,10 @@ function bindWhen(root, ctx, cleanups) {
|
|
|
189
189
|
continue;
|
|
190
190
|
}
|
|
191
191
|
const htmlEl = el;
|
|
192
|
-
//
|
|
192
|
+
// Apply initial state synchronously to avoid FOUC (flash of unstyled content)
|
|
193
|
+
const initialValue = !!resolve(binding);
|
|
194
|
+
htmlEl.style.display = initialValue ? '' : 'none';
|
|
195
|
+
// Then create reactive effect to keep it updated
|
|
193
196
|
effect(() => {
|
|
194
197
|
const value = !!resolve(binding);
|
|
195
198
|
htmlEl.style.display = value ? '' : 'none';
|
|
@@ -213,9 +216,8 @@ function bindMatch(root, ctx, cleanups) {
|
|
|
213
216
|
warn(`d-match: "${bindingName}" not found in context`);
|
|
214
217
|
continue;
|
|
215
218
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
// children (e.g. via d-if) are always up to date.
|
|
219
|
+
// Apply initial state synchronously to avoid FOUC
|
|
220
|
+
const applyMatch = () => {
|
|
219
221
|
const cases = Array.from(el.querySelectorAll('[case]'));
|
|
220
222
|
const v = resolve(binding);
|
|
221
223
|
const value = v == null ? '' : String(v);
|
|
@@ -239,6 +241,12 @@ function bindMatch(root, ctx, cleanups) {
|
|
|
239
241
|
else if (defaultEl) {
|
|
240
242
|
defaultEl.style.display = '';
|
|
241
243
|
}
|
|
244
|
+
};
|
|
245
|
+
// Apply initial state
|
|
246
|
+
applyMatch();
|
|
247
|
+
// Then create reactive effect to keep it updated
|
|
248
|
+
effect(() => {
|
|
249
|
+
applyMatch();
|
|
242
250
|
});
|
|
243
251
|
}
|
|
244
252
|
}
|
|
@@ -351,6 +359,12 @@ function bindIf(root, ctx, cleanups) {
|
|
|
351
359
|
el.parentNode?.replaceChild(comment, el);
|
|
352
360
|
el.removeAttribute('d-if');
|
|
353
361
|
const htmlEl = el;
|
|
362
|
+
// Apply initial state synchronously to avoid FOUC
|
|
363
|
+
const initialValue = !!resolve(binding);
|
|
364
|
+
if (initialValue) {
|
|
365
|
+
comment.parentNode?.insertBefore(htmlEl, comment);
|
|
366
|
+
}
|
|
367
|
+
// Then create reactive effect to keep it updated
|
|
354
368
|
effect(() => {
|
|
355
369
|
const value = !!resolve(binding);
|
|
356
370
|
if (value) {
|