Skip to content

Commit 7963c8d

Browse files
committed
Fix CSP issue with new x-json directive
1 parent 8d0572f commit 7963c8d

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

view/frontend/templates/component/debugger.phtml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ $htmlId = $idConvertor->toElementId($block->getNameInLayout());
7373
<code x-text="component.value"></code>
7474
</td>
7575
<td class="border-b border-gray-300 p-2">
76-
<?php /** @todo Make this CSP compliant */ ?>
77-
<code x-text="component.getDetailsString()"></code>
76+
<code x-json="component.getDetails"></code>
7877
</td>
7978
</tr>
8079
</template>

view/frontend/templates/script/component/debugger-component.phtml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<script>
2+
document.addEventListener('alpine:init', () => {
3+
Alpine.directive('json', (el, { value, expression }, { evaluate }) => {
4+
if (expression) {
5+
el.textContent = JSON.stringify(evaluate(expression));
6+
}
7+
});
8+
});
9+
</script>
10+
111
<script>
212
document.addEventListener('alpine:init', () => {
313
Alpine.data('LokiComponentsDebugger', () => ({
@@ -52,3 +62,4 @@
5262
}));
5363
});
5464
</script>
65+

0 commit comments

Comments
 (0)