-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add allowedTags to HTMLContentTransform request (#5347)
* Add allowedTags to HTMLContentTransform request * Add PR number * Add screenshot
- Loading branch information
Showing
7 changed files
with
173 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!doctype html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<script crossorigin="anonymous" src="/test-harness.js"></script> | ||
<script crossorigin="anonymous" src="/test-page-object.js"></script> | ||
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> | ||
</head> | ||
|
||
<body> | ||
<main id="webchat"></main> | ||
<script> | ||
run(async function () { | ||
const { | ||
WebChat: { renderWebChat } | ||
} = window; // Imports in UMD fashion. | ||
|
||
customElements.define( | ||
'my-world', | ||
class extends HTMLElement { | ||
connectedCallback() { | ||
this.append('🌎'); | ||
} | ||
} | ||
); | ||
|
||
const allowCustomElementsTransform = () => next => request => | ||
next({ | ||
...request, | ||
allowedTags: Object.freeze( | ||
new Map(request.allowedTags).set('my-world', Object.freeze({ attributes: Object.freeze([]) })) | ||
) | ||
}); | ||
|
||
const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
||
renderWebChat( | ||
{ directLine, htmlContentTransformMiddleware: [allowCustomElementsTransform], store }, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
await directLine.emulateIncomingActivity({ | ||
// Custom elements must not be self-closing. | ||
text: `Hello, <my-world></my-world>!`, | ||
type: 'message' | ||
}); | ||
|
||
await pageConditions.numActivitiesShown(1); | ||
|
||
// THEN: Should show as "Hello, 🌎!". | ||
expect(pageElements.activityContents()[0].textContent).toBe('Hello, 🌎!'); | ||
await host.snapshot('local'); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 12 additions & 88 deletions
100
packages/bundle/src/markdown/middleware/createSanitizeMiddleware.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...es/component/src/providers/HTMLContentTransformCOR/private/HTMLContentTransformContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters