Skip to content

Commit e3baa61

Browse files
authored
Remove setting dom policy during view template creation (#7130)
# Pull Request ## 📖 Description We may provide a hook for this later, but at present time it triggers the CSP trusted-types duplication error. ## ✅ Checklist ### General - [x] I have included a change request file using `$ npm run change` - [ ] I have added tests for my changes. - [x] I have tested my changes. - [ ] I have updated the project documentation to reflect my changes. - [x] I have read the [CONTRIBUTING](https://github.com/microsoft/fast/blob/main/CONTRIBUTING.md) documentation and followed the [standards](https://github.com/microsoft/fast/blob/main/CODE_OF_CONDUCT.md#our-standards) for this project.
1 parent 4701bd4 commit e3baa61

File tree

3 files changed

+9
-27
lines changed

3 files changed

+9
-27
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Remove setting explicit DOM policy as this causes an issue with CSP duplicate policy creation",
4+
"packageName": "@microsoft/fast-html",
5+
"email": "[email protected]",
6+
"dependentChangeType": "none"
7+
}

packages/web-components/fast-html/server/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function handlePathRequest(
1414
res: Response
1515
) {
1616
res.set("Content-Type", contentType);
17+
res.set("Content-Security-Policy", "trusted-types fast-html");
1718
fs.readFile(path.resolve(__dirname, mapPath), { encoding: "utf8" }, (err, data) => {
1819
const stream = (Readable as any).from(data);
1920

packages/web-components/fast-html/src/components/template.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import {
22
attr,
3-
DOMAspect,
4-
DOMSink,
53
FAST,
64
FASTElement,
75
FASTElementDefinition,
@@ -11,7 +9,6 @@ import {
119
ViewTemplate,
1210
} from "@microsoft/fast-element";
1311
import "@microsoft/fast-element/install-hydratable-view-templates.js";
14-
import { DOMPolicy } from "@microsoft/fast-element/dom-policy.js";
1512
import { Message } from "../interfaces.js";
1613
import {
1714
AttributeDirective,
@@ -31,17 +28,6 @@ interface ResolvedStringsAndValues {
3128
values: Array<any>;
3229
}
3330

34-
function allow(
35-
tagName: string | null,
36-
aspect: DOMAspect,
37-
aspectName: string,
38-
sink: DOMSink
39-
): DOMSink {
40-
return (target: Node, name: string, value: string, ...rest: any[]) => {
41-
sink(target, name, value, ...rest);
42-
};
43-
}
44-
4531
export interface ElementOptions {
4632
shadowOptions?: ShadowRootOptions | undefined;
4733
}
@@ -184,19 +170,7 @@ class TemplateElement extends FASTElement {
184170
strings: Array<string>,
185171
values: Array<any>
186172
): ViewTemplate<any, any> {
187-
return ViewTemplate.create(
188-
strings,
189-
values,
190-
DOMPolicy.create({
191-
guards: {
192-
aspects: {
193-
[DOMAspect.property]: {
194-
innerHTML: allow,
195-
},
196-
},
197-
},
198-
})
199-
);
173+
return ViewTemplate.create(strings, values);
200174
}
201175

202176
/**

0 commit comments

Comments
 (0)