Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/brown-ways-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@hashicorp/design-system-components": minor
---

<!-- START components/code-editor -->

`CodeEditor` - Added a `cspNonce` argument which passes a value of the same name to the `hds-code-editor` modifier. `cspNonce` is used to add a nonce value to the style tag

<!-- END -->
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
ariaDescribedBy=this.ariaDescribedBy
ariaLabel=@ariaLabel
ariaLabelledBy=this.ariaLabelledBy
cspNonce=@cspNonce
extraKeys=@extraKeys
hasLineWrapping=@hasLineWrapping
isLintingEnabled=@isLintingEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ module('Integration | Component | hds/code-editor/index', function (hooks) {
assert.dom('#test-code-editor').hasClass('hds-code-editor');
});

// cspNonce
test('it should render the injected style tag with the provided `@cspNonce` value', async function (assert) {
const cspNonce = 'csp-nonce-123';

this.set('cspNonce', cspNonce);

await setupCodeEditor(
hbs`<Hds::CodeEditor @cspNonce={{this.cspNonce}} as |CE|><CE.Title>Test Title</CE.Title></Hds::CodeEditor>`,
);

// can't use assert.dom to access elements in head
assert.ok(document.querySelector(`style[nonce="${cspNonce}"]`));
});

// title
test('it should render the component with a title using the default tag', async function (assert) {
await setupCodeEditor(
Expand Down