Update BaseDirective.js
parent
afd64097b3
commit
5b1727ad8a
|
@ -39,30 +39,30 @@ const BaseDirective = {
|
||||||
el._$instances = el._$instances || {};
|
el._$instances = el._$instances || {};
|
||||||
|
|
||||||
const config = binding?.instance?.$primevue?.config;
|
const config = binding?.instance?.$primevue?.config;
|
||||||
const $instance = el._$instances[name] || {};
|
const $prevInstance = el._$instances[name] || {};
|
||||||
const $options = ObjectUtils.isEmpty($instance) ? { ...options, ...options?.methods } : {};
|
const $options = ObjectUtils.isEmpty($prevInstance) ? { ...options, ...options?.methods } : {};
|
||||||
|
|
||||||
el.$instance = $instance;
|
|
||||||
el._$instances[name] = {
|
el._$instances[name] = {
|
||||||
...$instance,
|
...$prevInstance,
|
||||||
/* new instance variables to pass in directive methods */
|
/* new instance variables to pass in directive methods */
|
||||||
$name: name,
|
$name: name,
|
||||||
$host: el,
|
$host: el,
|
||||||
$binding: binding,
|
$binding: binding,
|
||||||
$el: $instance['$el'] || undefined,
|
$el: $prevInstance['$el'] || undefined,
|
||||||
$css: { classes: undefined, inlineStyles: undefined, loadStyle: () => {}, ...options?.css },
|
$css: { classes: undefined, inlineStyles: undefined, loadStyle: () => {}, ...options?.css },
|
||||||
/* computed instance variables */
|
/* computed instance variables */
|
||||||
defaultPT: config?.pt?.directives?.[name],
|
defaultPT: config?.pt?.directives?.[name],
|
||||||
isUnstyled: config?.unstyled,
|
isUnstyled: config?.unstyled,
|
||||||
/* instance's methods */
|
/* instance's methods */
|
||||||
ptm: (key = '', params = {}) => BaseDirective._getPTValue(el._$instances[name], el._$instances?.[name]?.$binding?.value?.pt, key, { ...params }),
|
ptm: (key = '', params = {}) => BaseDirective._getPTValue(el.$instance, el.$instance?.$binding?.value?.pt, key, { ...params }),
|
||||||
ptmo: (obj = {}, key = '', params = {}) => BaseDirective._getPTValue(el._$instances?.[name], obj, key, params, false),
|
ptmo: (obj = {}, key = '', params = {}) => BaseDirective._getPTValue(el.$instance, obj, key, params, false),
|
||||||
cx: (key = '', params = {}) => (!el._$instances?.[name]?.isUnstyled ? BaseDirective._getOptionValue(el._$instances?.[name]?.$css?.classes, key, { ...params }) : undefined),
|
cx: (key = '', params = {}) => (!el.$instance?.isUnstyled ? BaseDirective._getOptionValue(el.$instance?.$css?.classes, key, { ...params }) : undefined),
|
||||||
sx: (key = '', when = true, params = {}) => (when ? BaseDirective._getOptionValue(el._$instances?.[name]?.$css?.inlineStyles, key, { ...params }) : undefined),
|
sx: (key = '', when = true, params = {}) => (when ? BaseDirective._getOptionValue(el.$instance?.$css?.inlineStyles, key, { ...params }) : undefined),
|
||||||
...$options
|
...$options
|
||||||
};
|
};
|
||||||
|
|
||||||
$instance[hook]?.(el, binding, vnode, prevVnode); // handle hook in directive implementation
|
el.$instance = el._$instances[name]; // pass instance data to hooks
|
||||||
|
el.$instance[hook]?.(el, binding, vnode, prevVnode); // handle hook in directive implementation
|
||||||
BaseDirective._hook(name, hook, el, binding, vnode, prevVnode); // handle hooks during directive uses (global and self-definition)
|
BaseDirective._hook(name, hook, el, binding, vnode, prevVnode); // handle hooks during directive uses (global and self-definition)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -71,11 +71,11 @@ const BaseDirective = {
|
||||||
handleHook('created', el, binding, vnode, prevVnode);
|
handleHook('created', el, binding, vnode, prevVnode);
|
||||||
},
|
},
|
||||||
beforeMount: (el, binding, vnode, prevVnode) => {
|
beforeMount: (el, binding, vnode, prevVnode) => {
|
||||||
|
loadBaseStyle();
|
||||||
|
!el.$instance?.isUnstyled && el.$instance?.$css?.loadStyle();
|
||||||
handleHook('beforeMount', el, binding, vnode, prevVnode);
|
handleHook('beforeMount', el, binding, vnode, prevVnode);
|
||||||
},
|
},
|
||||||
mounted: (el, binding, vnode, prevVnode) => {
|
mounted: (el, binding, vnode, prevVnode) => {
|
||||||
loadBaseStyle();
|
|
||||||
!el.$instance?.isUnstyled && el.$instance?.$css?.loadStyle();
|
|
||||||
handleHook('mounted', el, binding, vnode, prevVnode);
|
handleHook('mounted', el, binding, vnode, prevVnode);
|
||||||
},
|
},
|
||||||
beforeUpdate: (el, binding, vnode, prevVnode) => {
|
beforeUpdate: (el, binding, vnode, prevVnode) => {
|
||||||
|
|
Loading…
Reference in New Issue