Skip to content

Commit 1f4673f

Browse files
authored
Widget mixin: Fix JS error when using both trendline & stylesheet (#2952)
Fixes #1423. Signed-off-by: Florian Hotze <[email protected]>
1 parent 802d412 commit 1f4673f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

bundles/org.openhab.ui/web/src/components/widgets/widget-mixin.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default {
2626
return widget.component
2727
},
2828
config () {
29-
if (!this.context || !this.context.component) return null
29+
if (!this.context?.component) return null
3030
let evalConfig = {}
3131
// Fallback to modelConfig for oh- components to allow configuring them in modals
3232
const sourceConfig = this.context.component.config || (this.componentType.startsWith('oh-') ? this.context.modalConfig : {})
@@ -40,8 +40,8 @@ export default {
4040
return evalConfig
4141
},
4242
props () {
43-
if (!this.context || !this.context.component) return {}
44-
if (this.context.component.props && this.context.component.props.parameters) {
43+
if (!this.context?.component) return {}
44+
if (this.context.component.props?.parameters) {
4545
let defaultValues = {}
4646
this.context.component.props.parameters.forEach((p) => {
4747
if (p.default !== undefined) {
@@ -63,14 +63,15 @@ export default {
6363
const user = this.$store.getters.user
6464
if (!user) return false
6565
if (user.roles && user.roles.some(r => visibleTo.indexOf('role:' + r) >= 0)) return true
66-
if (visibleTo.indexOf('user:' + user.name) >= 0) return true
67-
return false
66+
return visibleTo.indexOf('user:' + user.name) >= 0
6867
}
6968
return true
7069
}
7170
},
7271
mounted () {
73-
if (this.context && this.context.component && this.context.component.config && this.context.component.config.stylesheet) {
72+
if (this.context?.component?.config?.stylesheet) {
73+
if (!this.$el.classList) return // widget is not rendered yet, skip scoped styling
74+
7475
this.cssUid = 'scoped-' + this.$f7.utils.id()
7576

7677
this.$el.classList.add(this.cssUid)

0 commit comments

Comments
 (0)