Skip to content

Commit

Permalink
Fixed #6408 - Scoped style (dt props) does not attach to page with co…
Browse files Browse the repository at this point in the history
…rrect selector
  • Loading branch information
mertsincan committed Sep 16, 2024
1 parent 886f5f3 commit 335c6d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
9 changes: 4 additions & 5 deletions packages/core/src/basecomponent/BaseComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import { Theme, ThemeService } from '@primeuix/styled';
import { findSingle } from '@primeuix/utils/dom';
import { getKeyValue, isArray, isFunction, isNotEmpty, isString, resolve, toFlatCase } from '@primeuix/utils/object';
import { uuid } from '@primeuix/utils/uuid';
import Base from '@primevue/core/base';
import BaseStyle from '@primevue/core/base/style';
import { UniqueComponentId } from '@primevue/core/utils';
import { mergeProps } from 'vue';
import BaseComponentStyle from './style/BaseComponentStyle';
Expand Down Expand Up @@ -57,7 +57,9 @@ export default {
},
scopedStyleEl: undefined,
rootEl: undefined,
$attrSelector: undefined,
beforeCreate() {
this.$attrSelector = uuid('pc');
const _usept = this.pt?.['_usept'];
const originalValue = _usept ? this.pt?.originalValue?.[this.$.type.name] : undefined;
const value = _usept ? this.pt?.value?.[this.$.type.name] : this.pt;
Expand All @@ -83,7 +85,7 @@ export default {
if (this.rootEl) {
this.rootEl.setAttribute(this.$attrSelector, '');
this.rootEl.$pc = { name: this.$.type.name, ...this.$params };
this.rootEl.$pc = { name: this.$.type.name, attrSelector: this.$attrSelector, ...this.$params };
}
this._hook('onMounted');
Expand Down Expand Up @@ -370,9 +372,6 @@ export default {
return acc;
}, {});
},
$attrSelector() {
return UniqueComponentId('pc');
}
}
};
Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/basedirective/BaseDirective.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Theme, ThemeService } from '@primeuix/styled';
import { getKeyValue, isArray, isEmpty, isFunction, isObject, isString, resolve, toCapitalCase, toFlatCase } from '@primeuix/utils/object';
import { uuid } from '@primeuix/utils/uuid';
import Base from '@primevue/core/base';
import BaseStyle from '@primevue/core/base/style';
import PrimeVueService from '@primevue/core/service';
import { UniqueComponentId } from '@primevue/core/utils';
import { mergeProps } from 'vue';

const BaseDirective = {
Expand Down Expand Up @@ -166,7 +166,7 @@ const BaseDirective = {
$el: $prevInstance['$el'] || el || undefined,
$style: { classes: undefined, inlineStyles: undefined, load: () => {}, loadCSS: () => {}, loadTheme: () => {}, ...options?.style },
$primevueConfig: config,
$attrSelector: el.$attrSelector,
$attrSelector: el.$pd?.[name]?.attrSelector,
/* computed instance variables */
defaultPT: () => BaseDirective._getPT(config?.pt, undefined, (value) => value?.directives?.[name]),
isUnstyled: () => (el.$instance?.$binding?.value?.unstyled !== undefined ? el.$instance?.$binding?.value?.unstyled : config?.unstyled),
Expand Down Expand Up @@ -203,10 +203,11 @@ const BaseDirective = {

return {
created: (el, binding, vnode, prevVnode) => {
el.$pd ||= {};
el.$pd[name] = { name, attrSelector: uuid('pd') };
handleHook('created', el, binding, vnode, prevVnode);
},
beforeMount: (el, binding, vnode, prevVnode) => {
el.$attrSelector = UniqueComponentId('pd');
BaseDirective._loadStyles(el, binding, vnode);
handleHook('beforeMount', el, binding, vnode, prevVnode);
handleWatch(el);
Expand Down

0 comments on commit 335c6d8

Please sign in to comment.