@sprlab/wccompiler 0.8.4 → 0.8.5
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/adapters/vue.js +8 -2
- package/package.json +1 -1
package/adapters/vue.js
CHANGED
|
@@ -32,15 +32,21 @@
|
|
|
32
32
|
// This enables Vue's native v-model on WCC custom elements.
|
|
33
33
|
// Vue v-model on custom elements listens for `update:modelValue` by default.
|
|
34
34
|
// The nodeTransform in wccVuePlugin makes v-model:propName listen for `update:propName`.
|
|
35
|
+
//
|
|
36
|
+
// IMPORTANT: We listen in CAPTURE phase so the update:propName event is dispatched
|
|
37
|
+
// BEFORE Vue's own bubble-phase listeners process the element. This ensures Vue
|
|
38
|
+
// picks up the translated event synchronously.
|
|
35
39
|
|
|
36
40
|
if (typeof document !== 'undefined') {
|
|
37
41
|
document.addEventListener('wcc:model', (e) => {
|
|
38
42
|
const { prop, value } = e.detail;
|
|
43
|
+
// Dispatch update:propName synchronously on the target element.
|
|
44
|
+
// bubbles:false because Vue listens directly on the element via addEventListener.
|
|
39
45
|
e.target.dispatchEvent(new CustomEvent(`update:${prop}`, {
|
|
40
46
|
detail: value,
|
|
41
|
-
bubbles:
|
|
47
|
+
bubbles: false
|
|
42
48
|
}));
|
|
43
|
-
});
|
|
49
|
+
}, true); // ← capture phase
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
// ── Vue directive: v-wcc-model ──────────────────────────────────────
|
package/package.json
CHANGED