Refactor on directives
parent
0f0c9b95b2
commit
9b9444b6b0
|
@ -31,6 +31,7 @@ const BadgeDirective = BaseBadgeDirective.extend('badge', {
|
|||
!el.unstyled && DomHandler.addClass(badge, 'p-badge-dot');
|
||||
}
|
||||
|
||||
el.setAttribute('data-pd-badge', true);
|
||||
!el.unstyled && DomHandler.addClass(el, 'p-overlay-badge');
|
||||
el.setAttribute('data-p-overlay-badge', 'true');
|
||||
el.appendChild(badge);
|
||||
|
|
|
@ -15,13 +15,12 @@ const BaseDirective = {
|
|||
: ObjectUtils.getItemValue(options, params);
|
||||
},
|
||||
_getPTValue: (instance = {}, obj = {}, key = '', params = {}, searchInDefaultPT = true) => {
|
||||
const name = ObjectUtils.convertToFlatCase(instance.$name);
|
||||
const datasetPrefix = name ? `data-pd-${name}` : '';
|
||||
const datasetPrefix = 'data-pc-';
|
||||
const self = BaseDirective._getOptionValue(obj, key, params);
|
||||
const globalPT = searchInDefaultPT ? BaseDirective._getOptionValue(instance.defaultPT, key, params) : undefined;
|
||||
const merged = mergeProps(self, globalPT, {
|
||||
...(key === 'root' && { [datasetPrefix]: true }),
|
||||
[`${datasetPrefix}-section`]: ObjectUtils.convertToFlatCase(key)
|
||||
...(key === 'root' && { [`${datasetPrefix}name`]: ObjectUtils.convertToFlatCase(instance.$name) }),
|
||||
[`${datasetPrefix}section`]: ObjectUtils.convertToFlatCase(key)
|
||||
});
|
||||
|
||||
return merged;
|
||||
|
|
|
@ -11,9 +11,7 @@ const FocusTrap = BaseFocusTrap.extend('focustrap', {
|
|||
this.autoFocus(el, binding);
|
||||
}
|
||||
|
||||
DomHandler.setAttributes(el, {
|
||||
'p-bind': this.ptm('root')
|
||||
});
|
||||
el.setAttribute('data-pd-focustrap', true);
|
||||
|
||||
this.$el = el;
|
||||
},
|
||||
|
@ -111,11 +109,11 @@ const FocusTrap = BaseFocusTrap.extend('focustrap', {
|
|||
|
||||
firstFocusableElement.$_pfocustrap_lasthiddenfocusableelement = lastFocusableElement;
|
||||
firstFocusableElement.$_pfocustrap_focusableselector = firstFocusableSelector;
|
||||
firstFocusableElement.setAttribute('data-pd-focustrap-section', 'firstfocusableelement');
|
||||
firstFocusableElement.setAttribute('data-pc-section', 'firstfocusableelement');
|
||||
|
||||
lastFocusableElement.$_pfocustrap_firsthiddenfocusableelement = firstFocusableElement;
|
||||
lastFocusableElement.$_pfocustrap_focusableselector = lastFocusableSelector;
|
||||
lastFocusableElement.setAttribute('data-pd-focustrap-section', 'lastfocusableelement');
|
||||
lastFocusableElement.setAttribute('data-pc-section', 'lastfocusableelement');
|
||||
|
||||
el.prepend(firstFocusableElement);
|
||||
el.append(lastFocusableElement);
|
||||
|
|
|
@ -11,6 +11,8 @@ const Ripple = BaseRipple.extend('ripple', {
|
|||
this.create(el);
|
||||
this.bindEvents(el);
|
||||
}
|
||||
|
||||
el.setAttribute('data-pd-ripple', true);
|
||||
},
|
||||
unmounted(el) {
|
||||
this.remove(el);
|
||||
|
@ -91,7 +93,7 @@ const Ripple = BaseRipple.extend('ripple', {
|
|||
event.currentTarget.setAttribute('data-p-ink-active', 'false');
|
||||
},
|
||||
getInk(el) {
|
||||
return el && el.children ? [...el.children].find((child) => DomHandler.getAttribute(child, 'data-pd-ripple')) : undefined;
|
||||
return el && el.children ? [...el.children].find((child) => DomHandler.getAttribute(child, 'data-pc-name') === 'ripple') : undefined;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -3,6 +3,8 @@ import BaseStyleClass from './BaseStyleClass';
|
|||
|
||||
const StyleClass = BaseStyleClass.extend('styleclass', {
|
||||
mounted(el, binding) {
|
||||
el.setAttribute('data-pd-styleclass', true);
|
||||
|
||||
this.bind(el, binding);
|
||||
},
|
||||
unmounted(el) {
|
||||
|
|
|
@ -35,6 +35,8 @@ const Tooltip = BaseTooltip.extend('tooltip', {
|
|||
target.unstyled = options.instance.$primevue?.config?.unstyled || options.value?.unstyled || false;
|
||||
|
||||
this.bindEvents(target, options);
|
||||
|
||||
el.setAttribute('data-pd-tooltip', true);
|
||||
},
|
||||
updated(el, options) {
|
||||
let target = this.getTarget(el);
|
||||
|
|
Loading…
Reference in New Issue