From ebd0fa10b8c081df4e0644d625621b8102d515ff Mon Sep 17 00:00:00 2001 From: mertsincan Date: Fri, 18 Aug 2023 02:06:51 +0100 Subject: [PATCH] Fixed #4271 - Baseicon: Content Security Policy (CSP) violation --- components/lib/baseicon/BaseIcon.vue | 78 ++++++++++++++++------------ 1 file changed, 45 insertions(+), 33 deletions(-) diff --git a/components/lib/baseicon/BaseIcon.vue b/components/lib/baseicon/BaseIcon.vue index f68e733a2..0ed4b6349 100644 --- a/components/lib/baseicon/BaseIcon.vue +++ b/components/lib/baseicon/BaseIcon.vue @@ -1,38 +1,8 @@ - +`; + +const { load: loadStyle } = useStyle(styles, { name: 'baseicon', manual: true }); + +export default { + name: 'BaseIcon', + props: { + label: { + type: String, + default: undefined + }, + spin: { + type: Boolean, + default: false + } + }, + beforeMount() { + loadStyle(undefined, { nonce: this.$config?.csp?.nonce }); + }, + methods: { + pti() { + const isLabelEmpty = ObjectUtils.isEmpty(this.label); + + return { + class: [ + 'p-icon', + { + 'p-icon-spin': this.spin + } + ], + role: !isLabelEmpty ? 'img' : undefined, + 'aria-label': !isLabelEmpty ? this.label : undefined, + 'aria-hidden': isLabelEmpty + }; + } + }, + computed: { + $config() { + return this.$primevue?.config; + } + } +}; +