@@ -4,31 +4,28 @@ import { toRefs, watch, reactive } from "vue";
44 * We can't use 'style' as a component prop since it's a reserved property
55 * This function will map the special `styles` prop to `style`
66 */
7- function getRevisedProps ( props ) {
8- const revisedProps = { ...props } ;
9- delete revisedProps . styles ;
10- if ( props . styles ) {
11- props . style = props . styles ;
7+ function checkAndUpdateStylePropDef ( options , key ) {
8+ if ( key === "styles" ) {
9+ options . style = options [ key ] . value ;
1210 }
13- return revisedProps ;
1411}
1512
1613export default function usePropsAsObjectProperties ( props , ignoredKeys = [ ] ) {
17- const revisedProps = getRevisedProps ( props ) ;
18-
19- let options = toRefs ( revisedProps ) ;
14+ let options = toRefs ( props ) ;
2015 Object . keys ( options ) . forEach ( ( key ) => {
16+ checkAndUpdateStylePropDef ( options , key ) ;
2117 options [ key ] = options [ key ] . value ;
2218 } ) ;
2319
2420 const properties = reactive ( {
2521 ...options ,
2622 } ) ;
2723
28- watch ( props , ( newVal ) => {
29- options = toRefs ( getRevisedProps ( newVal ) ) ;
24+ watch ( props , ( ) => {
25+ options = toRefs ( props ) ;
3026 Object . keys ( options ) . forEach ( ( key ) => {
3127 if ( properties [ key ] != options [ key ] . value && ! ignoredKeys . includes ( key ) ) {
28+ checkAndUpdateStylePropDef ( options , key ) ;
3229 properties [ key ] = options [ key ] . value ;
3330 }
3431 } ) ;
0 commit comments