-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added value change support for native multi select (#3146)
- Loading branch information
Showing
5 changed files
with
88 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,31 @@ | ||
import { SetupContext } from 'vue'; | ||
|
||
type HTMLElementWithValueBinding = HTMLElement & { _value: unknown }; | ||
|
||
export const normalizeChildren = (context: SetupContext<any>, slotProps: any) => { | ||
if (!context.slots.default) { | ||
return context.slots.default; | ||
} | ||
|
||
return context.slots.default(slotProps); | ||
}; | ||
|
||
/** | ||
* Vue adds a `_value` prop at the moment on the input elements to store the REAL value on them, real values are different than the `value` attribute | ||
* as they do not get casted to strings unlike `el.value` which preserves user-code behavior | ||
*/ | ||
export function getBoundValue(el: HTMLElement): unknown { | ||
if (hasValueBinding(el)) { | ||
return el._value; | ||
} | ||
|
||
return undefined; | ||
} | ||
|
||
/** | ||
* Vue adds a `_value` prop at the moment on the input elements to store the REAL value on them, real values are different than the `value` attribute | ||
* as they do not get casted to strings unlike `el.value` which preserves user-code behavior | ||
*/ | ||
export function hasValueBinding(el: HTMLElement): el is HTMLElementWithValueBinding { | ||
return '_value' in el; | ||
} |