Skip to content

Commit 30870ad

Browse files
authored
Fix javascript error with policy button (#10049)
Fix javascript console error when createRoot is called on a non-existant element which is conditional. Resolves #10043
1 parent 0859c3a commit 30870ad

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

smarty/templates/main.tpl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,18 @@
7474
}
7575
});
7676
77-
headerPolicyRoot = ReactDOM.createRoot(
78-
document.getElementById("header-policy-button")
79-
);
80-
headerPolicyRoot.render(
81-
React.createElement(PolicyButton, {
82-
onClickPolicy: {$header_policy|json_encode},
83-
popUpPolicy: {$pop_up_policy|json_encode},
77+
const policyButtonEl = document.getElementById("header-policy-button");
78+
if (policyButtonEl) {
79+
headerPolicyRoot = ReactDOM.createRoot(
80+
policyButtonEl
81+
);
82+
headerPolicyRoot.render(
83+
React.createElement(PolicyButton, {
84+
onClickPolicy: {$header_policy|json_encode},
85+
popUpPolicy: {$pop_up_policy|json_encode},
8486
})
85-
);
87+
);
88+
}
8689
});
8790
</script>
8891
<link type="text/css" href="{$baseurl}/css/jqueryslidemenu.css" rel="Stylesheet" />

0 commit comments

Comments
 (0)