Skip to content

Commit 83f9ac0

Browse files
chore(deps-dev): Bump @stencil/vue-output-target from 0.8.6 to 0.8.7 in /core (#28508)
Bumps [@stencil/vue-output-target](https://github.com/ionic-team/stencil-ds-output-targets) from 0.8.6 to 0.8.7. <details> <summary>Commits</summary> <ul> <li>See full diff in <a href="https://github.com/ionic-team/stencil-ds-output-targets/commits">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=@stencil/vue-output-target&package-manager=npm_and_yarn&previous-version=0.8.6&new-version=0.8.7)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Liam DeBeasi <[email protected]>
1 parent a000dd2 commit 83f9ac0

File tree

6 files changed

+51
-69
lines changed

6 files changed

+51
-69
lines changed

core/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@stencil/angular-output-target": "^0.8.3",
5050
"@stencil/react-output-target": "^0.5.3",
5151
"@stencil/sass": "^3.0.7",
52-
"@stencil/vue-output-target": "^0.8.6",
52+
"@stencil/vue-output-target": "^0.8.7",
5353
"@types/jest": "^29.5.6",
5454
"@types/node": "^14.6.0",
5555
"@typescript-eslint/eslint-plugin": "^6.7.2",

core/stencil.config.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,20 +197,17 @@ export const config: Config = {
197197
{
198198
elements: ['ion-checkbox', 'ion-toggle'],
199199
targetAttr: 'checked',
200-
event: 'v-ion-change',
201-
externalEvent: 'ionChange'
200+
event: 'ion-change'
202201
},
203202
{
204203
elements: ['ion-datetime', 'ion-radio-group', 'ion-radio', 'ion-range', 'ion-segment', 'ion-segment-button', 'ion-select', 'ion-accordion-group'],
205204
targetAttr: 'value',
206-
event: 'v-ion-change',
207-
externalEvent: 'ionChange'
205+
event: 'ion-change',
208206
},
209207
{
210208
elements: ['ion-input', 'ion-searchbar', 'ion-textarea'],
211209
targetAttr: 'value',
212-
event: 'v-ion-input',
213-
externalEvent: 'ionInput'
210+
event: 'ion-input',
214211
}
215212
],
216213
}),

packages/vue/src/ionic-vue.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,10 @@ import type { App, Plugin } from "vue";
44

55
// TODO(FW-2969): types
66

7-
/**
8-
* We need to make sure that the web component fires an event
9-
* that will not conflict with the user's @ionChange binding,
10-
* otherwise the binding's callback will fire before any
11-
* v-model values have been updated.
12-
*/
137
const toKebabCase = (eventName: string) => {
14-
const kebabConvert = (name: string) =>
15-
name.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
16-
17-
switch (eventName) {
18-
case "ionInput":
19-
return "v-ion-input";
20-
case "ionChange":
21-
return "v-ion-change";
22-
default:
23-
return kebabConvert(eventName);
24-
}
8+
return eventName
9+
.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2")
10+
.toLowerCase();
2511
};
2612

2713
const getHelperFunctions = () => {

packages/vue/src/proxies.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export const IonAccordionGroup = /*@__PURE__*/ defineContainer<JSX.IonAccordionG
9595
'ionChange',
9696
'ionValueChange'
9797
],
98-
'value', 'v-ion-change', 'ionChange');
98+
'value', 'ion-change');
9999

100100

101101
export const IonAvatar = /*@__PURE__*/ defineContainer<JSX.IonAvatar>('ion-avatar', defineIonAvatar);
@@ -219,7 +219,7 @@ export const IonCheckbox = /*@__PURE__*/ defineContainer<JSX.IonCheckbox, JSX.Io
219219
'ionBlur',
220220
'ionStyle'
221221
],
222-
'checked', 'v-ion-change', 'ionChange');
222+
'checked', 'ion-change');
223223

224224

225225
export const IonChip = /*@__PURE__*/ defineContainer<JSX.IonChip>('ion-chip', defineIonChip, [
@@ -308,7 +308,7 @@ export const IonDatetime = /*@__PURE__*/ defineContainer<JSX.IonDatetime, JSX.Io
308308
'ionStyle',
309309
'ionRender'
310310
],
311-
'value', 'v-ion-change', 'ionChange');
311+
'value', 'ion-change');
312312

313313

314314
export const IonDatetimeButton = /*@__PURE__*/ defineContainer<JSX.IonDatetimeButton>('ion-datetime-button', defineIonDatetimeButton, [
@@ -435,7 +435,7 @@ export const IonInput = /*@__PURE__*/ defineContainer<JSX.IonInput, JSX.IonInput
435435
'ionFocus',
436436
'ionStyle'
437437
],
438-
'value', 'v-ion-input', 'ionInput');
438+
'value', 'ion-input');
439439

440440

441441
export const IonItem = /*@__PURE__*/ defineContainer<JSX.IonItem>('ion-item', defineIonItem, [
@@ -591,7 +591,7 @@ export const IonRadio = /*@__PURE__*/ defineContainer<JSX.IonRadio, JSX.IonRadio
591591
'ionFocus',
592592
'ionBlur'
593593
],
594-
'value', 'v-ion-change', 'ionChange');
594+
'value', 'ion-change');
595595

596596

597597
export const IonRadioGroup = /*@__PURE__*/ defineContainer<JSX.IonRadioGroup, JSX.IonRadioGroup["value"]>('ion-radio-group', defineIonRadioGroup, [
@@ -601,7 +601,7 @@ export const IonRadioGroup = /*@__PURE__*/ defineContainer<JSX.IonRadioGroup, JS
601601
'ionChange',
602602
'ionValueChange'
603603
],
604-
'value', 'v-ion-change', 'ionChange');
604+
'value', 'ion-change');
605605

606606

607607
export const IonRange = /*@__PURE__*/ defineContainer<JSX.IonRange, JSX.IonRange["value"]>('ion-range', defineIonRange, [
@@ -630,7 +630,7 @@ export const IonRange = /*@__PURE__*/ defineContainer<JSX.IonRange, JSX.IonRange
630630
'ionKnobMoveStart',
631631
'ionKnobMoveEnd'
632632
],
633-
'value', 'v-ion-change', 'ionChange');
633+
'value', 'ion-change');
634634

635635

636636
export const IonRefresher = /*@__PURE__*/ defineContainer<JSX.IonRefresher>('ion-refresher', defineIonRefresher, [
@@ -699,7 +699,7 @@ export const IonSearchbar = /*@__PURE__*/ defineContainer<JSX.IonSearchbar, JSX.
699699
'ionFocus',
700700
'ionStyle'
701701
],
702-
'value', 'v-ion-input', 'ionInput');
702+
'value', 'ion-input');
703703

704704

705705
export const IonSegment = /*@__PURE__*/ defineContainer<JSX.IonSegment, JSX.IonSegment["value"]>('ion-segment', defineIonSegment, [
@@ -713,7 +713,7 @@ export const IonSegment = /*@__PURE__*/ defineContainer<JSX.IonSegment, JSX.IonS
713713
'ionSelect',
714714
'ionStyle'
715715
],
716-
'value', 'v-ion-change', 'ionChange');
716+
'value', 'ion-change');
717717

718718

719719
export const IonSegmentButton = /*@__PURE__*/ defineContainer<JSX.IonSegmentButton, JSX.IonSegmentButton["value"]>('ion-segment-button', defineIonSegmentButton, [
@@ -722,7 +722,7 @@ export const IonSegmentButton = /*@__PURE__*/ defineContainer<JSX.IonSegmentButt
722722
'type',
723723
'value'
724724
],
725-
'value', 'v-ion-change', 'ionChange');
725+
'value', 'ion-change');
726726

727727

728728
export const IonSelect = /*@__PURE__*/ defineContainer<JSX.IonSelect, JSX.IonSelect["value"]>('ion-select', defineIonSelect, [
@@ -753,7 +753,7 @@ export const IonSelect = /*@__PURE__*/ defineContainer<JSX.IonSelect, JSX.IonSel
753753
'ionBlur',
754754
'ionStyle'
755755
],
756-
'value', 'v-ion-change', 'ionChange');
756+
'value', 'ion-change');
757757

758758

759759
export const IonSelectOption = /*@__PURE__*/ defineContainer<JSX.IonSelectOption>('ion-select-option', defineIonSelectOption, [
@@ -824,7 +824,7 @@ export const IonTextarea = /*@__PURE__*/ defineContainer<JSX.IonTextarea, JSX.Io
824824
'ionBlur',
825825
'ionFocus'
826826
],
827-
'value', 'v-ion-input', 'ionInput');
827+
'value', 'ion-input');
828828

829829

830830
export const IonThumbnail = /*@__PURE__*/ defineContainer<JSX.IonThumbnail>('ion-thumbnail', defineIonThumbnail);
@@ -853,7 +853,7 @@ export const IonToggle = /*@__PURE__*/ defineContainer<JSX.IonToggle, JSX.IonTog
853853
'ionBlur',
854854
'ionStyle'
855855
],
856-
'checked', 'v-ion-change', 'ionChange');
856+
'checked', 'ion-change');
857857

858858

859859
export const IonToolbar = /*@__PURE__*/ defineContainer<JSX.IonToolbar>('ion-toolbar', defineIonToolbar, [

packages/vue/src/vue-component-lib/utils.ts

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-nocheck
22
// It's easier and safer for Volar to disable typechecking and let the return type inference do its job.
3-
import { VNode, defineComponent, getCurrentInstance, h, inject, ref, Ref } from 'vue';
3+
import { defineComponent, getCurrentInstance, h, inject, ref, Ref, withDirectives } from 'vue';
44

55
export interface InputProps<T> {
66
modelValue?: T;
@@ -53,16 +53,13 @@ const getElementClasses = (
5353
* to customElements.define. Only set if `includeImportCustomElements: true` in your config.
5454
* @prop modelProp - The prop that v-model binds to (i.e. value)
5555
* @prop modelUpdateEvent - The event that is fired from your Web Component when the value changes (i.e. ionChange)
56-
* @prop externalModelUpdateEvent - The external event to fire from your Vue component when modelUpdateEvent fires. This is used for ensuring that v-model references have been
57-
* correctly updated when a user's event callback fires.
5856
*/
5957
export const defineContainer = <Props, VModelType = string | number | boolean>(
6058
name: string,
6159
defineCustomElement: any,
6260
componentProps: string[] = [],
6361
modelProp?: string,
64-
modelUpdateEvent?: string,
65-
externalModelUpdateEvent?: string
62+
modelUpdateEvent?: string
6663
) => {
6764
/**
6865
* Create a Vue component wrapper around a Web Component.
@@ -78,29 +75,27 @@ export const defineContainer = <Props, VModelType = string | number | boolean>(
7875
let modelPropValue = props[modelProp];
7976
const containerRef = ref<HTMLElement>();
8077
const classes = new Set(getComponentClasses(attrs.class));
81-
const onVnodeBeforeMount = (vnode: VNode) => {
82-
// Add a listener to tell Vue to update the v-model
83-
if (vnode.el) {
78+
79+
/**
80+
* This directive is responsible for updating any reactive
81+
* reference associated with v-model on the component.
82+
* This code must be run inside of the "created" callback.
83+
* Since the following listener callbacks as well as any potential
84+
* event callback defined in the developer's app are set on
85+
* the same element, we need to make sure the following callbacks
86+
* are set first so they fire first. If the developer's callback fires first
87+
* then the reactive reference will not have been updated yet.
88+
*/
89+
const vModelDirective = {
90+
created: (el: HTMLElement) => {
8491
const eventsNames = Array.isArray(modelUpdateEvent) ? modelUpdateEvent : [modelUpdateEvent];
8592
eventsNames.forEach((eventName: string) => {
86-
vnode.el!.addEventListener(eventName.toLowerCase(), (e: Event) => {
93+
el.addEventListener(eventName.toLowerCase(), (e: Event) => {
8794
modelPropValue = (e?.target as any)[modelProp];
8895
emit(UPDATE_VALUE_EVENT, modelPropValue);
89-
90-
/**
91-
* We need to emit the change event here
92-
* rather than on the web component to ensure
93-
* that any v-model bindings have been updated.
94-
* Otherwise, the developer will listen on the
95-
* native web component, but the v-model will
96-
* not have been updated yet.
97-
*/
98-
if (externalModelUpdateEvent) {
99-
emit(externalModelUpdateEvent, e);
100-
}
10196
});
10297
});
103-
}
98+
},
10499
};
105100

106101
const currentInstance = getCurrentInstance();
@@ -146,7 +141,6 @@ export const defineContainer = <Props, VModelType = string | number | boolean>(
146141
ref: containerRef,
147142
class: getElementClasses(containerRef, classes),
148143
onClick: handleClick,
149-
onVnodeBeforeMount: modelUpdateEvent ? onVnodeBeforeMount : undefined,
150144
};
151145

152146
/**
@@ -182,7 +176,12 @@ export const defineContainer = <Props, VModelType = string | number | boolean>(
182176
}
183177
}
184178

185-
return h(name, propsToAdd, slots.default && slots.default());
179+
/**
180+
* vModelDirective is only needed on components that support v-model.
181+
* As a result, we conditionally call withDirectives with v-model components.
182+
*/
183+
const node = h(name, propsToAdd, slots.default && slots.default());
184+
return modelProp === undefined ? node : withDirectives(node, [[vModelDirective]]);
186185
};
187186
});
188187

@@ -199,7 +198,7 @@ export const defineContainer = <Props, VModelType = string | number | boolean>(
199198

200199
if (modelProp) {
201200
Container.props[MODEL_VALUE] = DEFAULT_EMPTY_PROP;
202-
Container.emits = [UPDATE_VALUE_EVENT, externalModelUpdateEvent];
201+
Container.emits = [UPDATE_VALUE_EVENT];
203202
}
204203
}
205204

0 commit comments

Comments
 (0)