Fixed #4271 - Baseicon: Content Security Policy (CSP) violation

pull/4295/head
mertsincan 2023-08-18 02:06:51 +01:00
parent 37979a7d50
commit ebd0fa10b8
1 changed files with 45 additions and 33 deletions

View File

@ -1,38 +1,8 @@
<script>
import { useStyle } from 'primevue/usestyle';
import { ObjectUtils } from 'primevue/utils';
export default {
name: 'BaseIcon',
props: {
label: {
type: String,
default: undefined
},
spin: {
type: Boolean,
default: false
}
},
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
};
}
}
};
</script>
<style>
const styles = `
.p-icon {
display: inline-block;
}
@ -63,4 +33,46 @@ export default {
transform: rotate(359deg);
}
}
</style>
`;
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;
}
}
};
</script>