@microsoft/fast-element 2.0.0-beta.17 → 2.0.0-beta.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.json +21 -0
  2. package/CHANGELOG.md +10 -1
  3. package/dist/dts/dom-policy.d.ts +68 -0
  4. package/dist/dts/dom.d.ts +116 -0
  5. package/dist/dts/index.d.ts +3 -2
  6. package/dist/dts/index.rollup.d.ts +0 -1
  7. package/dist/dts/index.rollup.debug.d.ts +0 -1
  8. package/dist/dts/interfaces.d.ts +15 -24
  9. package/dist/dts/polyfills.d.ts +0 -1
  10. package/dist/dts/templating/binding-signal.d.ts +3 -1
  11. package/dist/dts/templating/binding-two-way.d.ts +3 -1
  12. package/dist/dts/templating/binding.d.ts +16 -5
  13. package/dist/dts/templating/compiler.d.ts +11 -13
  14. package/dist/dts/templating/dangerous-html.d.ts +18 -0
  15. package/dist/dts/templating/html-directive.d.ts +50 -119
  16. package/dist/dts/templating/node-observation.d.ts +11 -1
  17. package/dist/dts/templating/ref.d.ts +4 -0
  18. package/dist/dts/templating/render.d.ts +30 -6
  19. package/dist/dts/templating/repeat.d.ts +1 -5
  20. package/dist/dts/templating/template.d.ts +39 -13
  21. package/dist/dts/templating/view.d.ts +2 -2
  22. package/dist/dts/utilities.d.ts +39 -0
  23. package/dist/esm/components/attributes.js +1 -1
  24. package/dist/esm/debug.js +4 -1
  25. package/dist/esm/dom-policy.js +337 -0
  26. package/dist/esm/dom.js +117 -0
  27. package/dist/esm/index.js +2 -1
  28. package/dist/esm/index.rollup.debug.js +3 -1
  29. package/dist/esm/index.rollup.js +3 -1
  30. package/dist/esm/platform.js +1 -1
  31. package/dist/esm/polyfills.js +3 -7
  32. package/dist/esm/templating/binding-signal.js +3 -2
  33. package/dist/esm/templating/binding-two-way.js +3 -2
  34. package/dist/esm/templating/binding.js +31 -54
  35. package/dist/esm/templating/compiler.js +31 -38
  36. package/dist/esm/templating/dangerous-html.js +23 -0
  37. package/dist/esm/templating/html-directive.js +38 -135
  38. package/dist/esm/templating/node-observation.js +14 -8
  39. package/dist/esm/templating/ref.js +1 -1
  40. package/dist/esm/templating/render.js +17 -6
  41. package/dist/esm/templating/repeat.js +2 -6
  42. package/dist/esm/templating/template.js +81 -56
  43. package/dist/esm/testing/fixture.js +1 -1
  44. package/dist/esm/utilities.js +68 -0
  45. package/dist/fast-element.api.json +1088 -608
  46. package/dist/fast-element.d.ts +190 -147
  47. package/dist/fast-element.debug.js +708 -384
  48. package/dist/fast-element.debug.min.js +1 -1
  49. package/dist/fast-element.js +679 -358
  50. package/dist/fast-element.min.js +1 -1
  51. package/dist/fast-element.untrimmed.d.ts +190 -147
  52. package/docs/api-report.md +66 -56
  53. package/package.json +5 -1
  54. package/yarn-error.log +177 -0
  55. package/dist/dts/templating/dom.d.ts +0 -41
  56. package/dist/esm/templating/dom.js +0 -49
@@ -76,55 +76,6 @@ export declare const ArrayObserver: Readonly<{
76
76
  readonly enable: () => void;
77
77
  }>;
78
78
 
79
- /**
80
- * The type of HTML aspect to target.
81
- * @public
82
- */
83
- export declare const Aspect: Readonly<{
84
- /**
85
- * Not aspected.
86
- */
87
- readonly none: 0;
88
- /**
89
- * An attribute.
90
- */
91
- readonly attribute: 1;
92
- /**
93
- * A boolean attribute.
94
- */
95
- readonly booleanAttribute: 2;
96
- /**
97
- * A property.
98
- */
99
- readonly property: 3;
100
- /**
101
- * Content
102
- */
103
- readonly content: 4;
104
- /**
105
- * A token list.
106
- */
107
- readonly tokenList: 5;
108
- /**
109
- * An event.
110
- */
111
- readonly event: 6;
112
- /**
113
- *
114
- * @param directive - The directive to assign the aspect to.
115
- * @param value - The value to base the aspect determination on.
116
- * @remarks
117
- * If a falsy value is provided, then the content aspect will be assigned.
118
- */
119
- readonly assign: (directive: Aspected, value?: string) => void;
120
- }>;
121
-
122
- /**
123
- * The type of HTML aspect to target.
124
- * @public
125
- */
126
- export declare type Aspect = typeof Aspect[Exclude<keyof typeof Aspect, "assign" | "none">];
127
-
128
79
  /**
129
80
  * Represents something that applies to a specific aspect of the DOM.
130
81
  * @public
@@ -141,7 +92,7 @@ export declare interface Aspected {
141
92
  /**
142
93
  * The type of aspect to target.
143
94
  */
144
- aspectType: Aspect;
95
+ aspectType: DOMAspect;
145
96
  /**
146
97
  * A binding if one is associated with the aspect.
147
98
  */
@@ -266,11 +217,12 @@ export declare type AttributeMode = typeof reflectMode | typeof booleanMode | "f
266
217
  /**
267
218
  * Creates an standard binding.
268
219
  * @param expression - The binding to refresh when changed.
220
+ * @param policy - The security policy to associate with th binding.
269
221
  * @param isVolatile - Indicates whether the binding is volatile or not.
270
222
  * @returns A binding configuration.
271
223
  * @public
272
224
  */
273
- export declare function bind<T = any>(expression: Expression<T>, isVolatile?: boolean): Binding<T>;
225
+ export declare function bind<T = any>(expression: Expression<T>, policy?: DOMPolicy, isVolatile?: boolean): Binding<T>;
274
226
 
275
227
  /**
276
228
  * Captures a binding expression along with related information and capabilities.
@@ -279,6 +231,7 @@ export declare function bind<T = any>(expression: Expression<T>, isVolatile?: bo
279
231
  */
280
232
  export declare abstract class Binding<TSource = any, TReturn = any, TParent = any> {
281
233
  evaluate: Expression<TSource, TReturn, TParent>;
234
+ policy?: DOMPolicy | undefined;
282
235
  isVolatile: boolean;
283
236
  /**
284
237
  * Options associated with the binding.
@@ -287,9 +240,10 @@ export declare abstract class Binding<TSource = any, TReturn = any, TParent = an
287
240
  /**
288
241
  * Creates a binding.
289
242
  * @param evaluate - Evaluates the binding.
243
+ * @param policy - The security policy to associate with this binding.
290
244
  * @param isVolatile - Indicates whether the binding is volatile.
291
245
  */
292
- constructor(evaluate: Expression<TSource, TReturn, TParent>, isVolatile?: boolean);
246
+ constructor(evaluate: Expression<TSource, TReturn, TParent>, policy?: DOMPolicy | undefined, isVolatile?: boolean);
293
247
  /**
294
248
  * Creates an observer capable of notifying a subscriber when the output of a binding changes.
295
249
  * @param directive - The HTML Directive to create the observer for.
@@ -387,33 +341,36 @@ html: string | HTMLTemplateElement,
387
341
  /**
388
342
  * The behavior factories used within the html that is being compiled.
389
343
  */
390
- factories: Record<string, ViewBehaviorFactory>) => HTMLTemplateCompilationResult;
344
+ factories: Record<string, ViewBehaviorFactory>,
345
+ /**
346
+ * The security policy to compile the html with.
347
+ */
348
+ policy: DOMPolicy) => HTMLTemplateCompilationResult;
349
+
350
+ /**
351
+ * Represents a ViewBehaviorFactory after the compilation process has completed.
352
+ * @public
353
+ */
354
+ export declare type CompiledViewBehaviorFactory = Required<ViewBehaviorFactory>;
391
355
 
392
356
  /**
393
357
  * Common APIs related to compilation.
394
358
  * @public
395
359
  */
396
360
  export declare const Compiler: {
397
- /**
398
- * Sets the HTML trusted types policy used by the compiler.
399
- * @param policy - The policy to set for HTML.
400
- * @remarks
401
- * This API can only be called once, for security reasons. It should be
402
- * called by the application developer at the start of their program.
403
- */
404
- setHTMLPolicy(policy: TrustedTypesPolicy): void;
405
361
  /**
406
362
  * Compiles a template and associated directives into a compilation
407
363
  * result which can be used to create views.
408
364
  * @param html - The html string or template element to compile.
409
- * @param directives - The directives referenced by the template.
365
+ * @param factories - The behavior factories referenced by the template.
366
+ * @param policy - The security policy to compile the html with.
410
367
  * @remarks
411
368
  * The template that is provided for compilation is altered in-place
412
369
  * and cannot be compiled again. If the original template must be preserved,
413
370
  * it is recommended that you clone the original and pass the clone to this API.
414
371
  * @public
415
372
  */
416
- compile<TSource = any, TParent = any>(html: string | HTMLTemplateElement, directives: Record<string, ViewBehaviorFactory>): HTMLTemplateCompilationResult<TSource, TParent>;
373
+ compile<TSource = any, TParent = any>(html: string | HTMLTemplateElement, factories: Record<string, ViewBehaviorFactory>, policy?: DOMPolicy): HTMLTemplateCompilationResult<TSource, TParent>;
417
374
  /**
418
375
  * Sets the default compilation strategy that will be used by the ViewTemplate whenever
419
376
  * it needs to compile a view preprocessed with the html template function.
@@ -424,9 +381,10 @@ export declare const Compiler: {
424
381
  * Aggregates an array of strings and directives into a single directive.
425
382
  * @param parts - A heterogeneous array of static strings interspersed with
426
383
  * directives.
384
+ * @param policy - The security policy to use with the aggregated bindings.
427
385
  * @returns A single inline directive that aggregates the behavior of all the parts.
428
386
  */
429
- aggregate(parts: (string | ViewBehaviorFactory)[]): ViewBehaviorFactory;
387
+ aggregate(parts: (string | ViewBehaviorFactory)[], policy?: DOMPolicy): ViewBehaviorFactory;
430
388
  };
431
389
 
432
390
  /**
@@ -608,6 +566,24 @@ export declare type CSSTemplateTag = ((strings: TemplateStringsArray, ...values:
608
566
  */
609
567
  export declare function customElement(nameOrDef: string | PartialFASTElementDefinition): (type: Constructable<HTMLElement>) => void;
610
568
 
569
+ /**
570
+ * Injects static HTML without platform protection.
571
+ * @param html - The html to injection.
572
+ * @returns A DangerousHTMLDirective.
573
+ * @public
574
+ */
575
+ export declare function dangerousHTML<TSource = any, TParent = any>(html: string): CaptureType<TSource, TParent>;
576
+
577
+ /**
578
+ * A directive capable of injecting static HTML platform runtime protection.
579
+ * @public
580
+ */
581
+ export declare class DangerousHTMLDirective implements HTMLDirective {
582
+ private html;
583
+ constructor(html: string);
584
+ createHTML(): string;
585
+ }
586
+
611
587
  /**
612
588
  * Metadata used to configure a custom attribute's behavior through a decorator.
613
589
  * @public
@@ -649,6 +625,18 @@ export declare const DOM: Readonly<{
649
625
  * Use Updates.process()
650
626
  */
651
627
  processUpdates: () => void;
628
+ /**
629
+ * Gets the dom policy used by the templating system.
630
+ */
631
+ readonly policy: DOMPolicy;
632
+ /**
633
+ * Sets the dom policy used by the templating system.
634
+ * @param policy - The policy to set.
635
+ * @remarks
636
+ * This API can only be called once, for security reasons. It should be
637
+ * called by the application developer at the start of their program.
638
+ */
639
+ setPolicy(value: DOMPolicy): void;
652
640
  /**
653
641
  * Sets an attribute value on an element.
654
642
  * @param element - The element to set the attribute value on.
@@ -670,6 +658,73 @@ export declare const DOM: Readonly<{
670
658
  setBooleanAttribute(element: HTMLElement, attributeName: string, value: boolean): void;
671
659
  }>;
672
660
 
661
+ /**
662
+ * The type of HTML aspect to target.
663
+ * @public
664
+ */
665
+ export declare const DOMAspect: Readonly<{
666
+ /**
667
+ * Not aspected.
668
+ */
669
+ readonly none: 0;
670
+ /**
671
+ * An attribute.
672
+ */
673
+ readonly attribute: 1;
674
+ /**
675
+ * A boolean attribute.
676
+ */
677
+ readonly booleanAttribute: 2;
678
+ /**
679
+ * A property.
680
+ */
681
+ readonly property: 3;
682
+ /**
683
+ * Content
684
+ */
685
+ readonly content: 4;
686
+ /**
687
+ * A token list.
688
+ */
689
+ readonly tokenList: 5;
690
+ /**
691
+ * An event.
692
+ */
693
+ readonly event: 6;
694
+ }>;
695
+
696
+ /**
697
+ * The type of HTML aspect to target.
698
+ * @public
699
+ */
700
+ export declare type DOMAspect = typeof DOMAspect[Exclude<keyof typeof DOMAspect, "none">];
701
+
702
+ /**
703
+ * A security policy that FAST can use to interact with the DOM.
704
+ * @public
705
+ */
706
+ export declare interface DOMPolicy {
707
+ /**
708
+ * Creates safe HTML from the provided value.
709
+ * @param value - The source to convert to safe HTML.
710
+ */
711
+ createHTML(value: string): string;
712
+ /**
713
+ * Protects a DOM sink that intends to write to the DOM.
714
+ * @param tagName - The tag name for the element to write to.
715
+ * @param aspect - The aspect of the DOM to write to.
716
+ * @param aspectName - The name of the aspect to write to.
717
+ * @param sink - The sink that is used to write to the DOM.
718
+ */
719
+ protect(tagName: string | null, aspect: DOMAspect, aspectName: string, sink: DOMSink): DOMSink;
720
+ }
721
+
722
+ /**
723
+ * A function used to send values to a DOM sink.
724
+ * @public
725
+ */
726
+ export declare type DOMSink = (target: Node, aspectName: string, value: any, ...args: any[]) => void;
727
+
673
728
  /**
674
729
  * Controls the lifecycle and rendering of a `FASTElement`.
675
730
  * @public
@@ -1362,7 +1417,15 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
1362
1417
  /**
1363
1418
  * The structural id of the DOM node to which the created behavior will apply.
1364
1419
  */
1365
- nodeId: string;
1420
+ targetNodeId: string;
1421
+ /**
1422
+ * The tagname associated with the target node.
1423
+ */
1424
+ targetTagName: string | null;
1425
+ /**
1426
+ * The policy that the created behavior must run under.
1427
+ */
1428
+ policy: DOMPolicy;
1366
1429
  /**
1367
1430
  * The original source aspect exactly as represented in markup.
1368
1431
  */
@@ -1374,7 +1437,7 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
1374
1437
  /**
1375
1438
  * The type of aspect to target.
1376
1439
  */
1377
- aspectType: Aspect;
1440
+ aspectType: DOMAspect;
1378
1441
  /**
1379
1442
  * Creates an instance of HTMLBindingDirective.
1380
1443
  * @param dataBinding - The binding configuration to apply.
@@ -1432,6 +1495,14 @@ export declare const HTMLDirective: Readonly<{
1432
1495
  * @param options - Options that specify the directive's application.
1433
1496
  */
1434
1497
  define<TType extends Constructable<HTMLDirective>>(type: TType, options?: PartialHTMLDirectiveDefinition): TType;
1498
+ /**
1499
+ *
1500
+ * @param directive - The directive to assign the aspect to.
1501
+ * @param value - The value to base the aspect determination on.
1502
+ * @remarks
1503
+ * If a falsy value is provided, then the content aspect will be assigned.
1504
+ */
1505
+ assignAspect(directive: Aspected, value?: string): void;
1435
1506
  }>;
1436
1507
 
1437
1508
  /**
@@ -1556,7 +1627,7 @@ export declare class HTMLView<TSource = any, TParent = any> implements ElementVi
1556
1627
  * @param fragment - The html fragment that contains the nodes for this view.
1557
1628
  * @param behaviors - The behaviors to be applied to this view.
1558
1629
  */
1559
- constructor(fragment: DocumentFragment, factories: ReadonlyArray<ViewBehaviorFactory>, targets: ViewBehaviorTargets);
1630
+ constructor(fragment: DocumentFragment, factories: ReadonlyArray<CompiledViewBehaviorFactory>, targets: ViewBehaviorTargets);
1560
1631
  /**
1561
1632
  * Appends the view's DOM nodes to the referenced node.
1562
1633
  * @param node - The parent node to append the view's DOM nodes to.
@@ -1696,7 +1767,17 @@ export declare interface NodeBehaviorOptions<T = any> {
1696
1767
  * Internally used by the SlottedDirective and the ChildrenDirective.
1697
1768
  */
1698
1769
  export declare abstract class NodeObservationDirective<T extends NodeBehaviorOptions> extends StatelessAttachedAttributeDirective<T> {
1699
- private controllerProperty;
1770
+ private _id;
1771
+ private _controllerProperty;
1772
+ /**
1773
+ * The unique id of the factory.
1774
+ */
1775
+ get id(): string;
1776
+ set id(value: string);
1777
+ /**
1778
+ * The structural id of the DOM node to which the created behavior will apply.
1779
+ */
1780
+ targetNodeId: string;
1700
1781
  /**
1701
1782
  * Bind this behavior to the source.
1702
1783
  * @param source - The source to bind to.
@@ -1887,10 +1968,11 @@ export declare interface ObservationRecord {
1887
1968
  /**
1888
1969
  * Creates a one time binding
1889
1970
  * @param expression - The binding to refresh when signaled.
1971
+ * @param policy - The security policy to associate with th binding.
1890
1972
  * @returns A binding configuration.
1891
1973
  * @public
1892
1974
  */
1893
- export declare function oneTime<T = any>(expression: Expression<T>): Binding<T>;
1975
+ export declare function oneTime<T = any>(expression: Expression<T>, policy?: DOMPolicy): Binding<T>;
1894
1976
 
1895
1977
  /**
1896
1978
  * Common APIs related to content parsing.
@@ -2008,6 +2090,10 @@ export declare const ref: <TSource = any, TParent = any>(propertyName: keyof TSo
2008
2090
  * @public
2009
2091
  */
2010
2092
  export declare class RefDirective extends StatelessAttachedAttributeDirective<string> {
2093
+ /**
2094
+ * The structural id of the DOM node to which the created behavior will apply.
2095
+ */
2096
+ targetNodeId: string;
2011
2097
  /**
2012
2098
  * Bind this behavior.
2013
2099
  * @param controller - The view controller that manages the lifecycle of this behavior.
@@ -2082,14 +2168,10 @@ export declare class RepeatDirective<TSource = any> implements HTMLDirective, Vi
2082
2168
  readonly dataBinding: Binding<TSource>;
2083
2169
  readonly templateBinding: Binding<TSource, SyntheticViewTemplate>;
2084
2170
  readonly options: RepeatOptions;
2085
- /**
2086
- * The unique id of the factory.
2087
- */
2088
- id: string;
2089
2171
  /**
2090
2172
  * The structural id of the DOM node to which the created behavior will apply.
2091
2173
  */
2092
- nodeId: string;
2174
+ targetNodeId: string;
2093
2175
  /**
2094
2176
  * Creates a placeholder string based on the directive's index within the template.
2095
2177
  * @param index - The index of the directive within the template.
@@ -2356,14 +2438,6 @@ export declare type SpliceStrategySupport = typeof SpliceStrategySupport[keyof t
2356
2438
  */
2357
2439
  export declare abstract class StatelessAttachedAttributeDirective<TOptions> implements HTMLDirective, ViewBehaviorFactory, ViewBehavior {
2358
2440
  protected options: TOptions;
2359
- /**
2360
- * The unique id of the factory.
2361
- */
2362
- id: string;
2363
- /**
2364
- * The structural id of the DOM node to which the created behavior will apply.
2365
- */
2366
- nodeId: string;
2367
2441
  /**
2368
2442
  * Opts out of JSON stringification.
2369
2443
  * @internal
@@ -2555,31 +2629,6 @@ export declare interface SyntheticViewTemplate<TSource = any, TParent = any> {
2555
2629
  */
2556
2630
  export declare type TemplateValue<TSource, TParent = any> = Expression<TSource, any, TParent> | Binding<TSource, any, TParent> | HTMLDirective | CaptureType<TSource, TParent>;
2557
2631
 
2558
- /**
2559
- * Enables working with trusted types.
2560
- * @public
2561
- */
2562
- export declare type TrustedTypes = {
2563
- /**
2564
- * Creates a trusted types policy.
2565
- * @param name - The policy name.
2566
- * @param rules - The policy rules implementation.
2567
- */
2568
- createPolicy(name: string, rules: TrustedTypesPolicy): TrustedTypesPolicy;
2569
- };
2570
-
2571
- /**
2572
- * A policy for use with the standard trustedTypes platform API.
2573
- * @public
2574
- */
2575
- export declare type TrustedTypesPolicy = {
2576
- /**
2577
- * Creates trusted HTML.
2578
- * @param html - The HTML to clear as trustworthy.
2579
- */
2580
- createHTML(html: string): string;
2581
- };
2582
-
2583
2632
  /**
2584
2633
  * Do not change. Part of shared kernel contract.
2585
2634
  * @internal
@@ -2702,56 +2751,25 @@ export declare interface ViewBehaviorFactory {
2702
2751
  /**
2703
2752
  * The unique id of the factory.
2704
2753
  */
2705
- id: string;
2754
+ id?: string;
2706
2755
  /**
2707
2756
  * The structural id of the DOM node to which the created behavior will apply.
2708
2757
  */
2709
- nodeId: string;
2758
+ targetNodeId?: string;
2710
2759
  /**
2711
- * Creates a behavior.
2760
+ * The tag name of the DOM node to which the created behavior will apply.
2712
2761
  */
2713
- createBehavior(): ViewBehavior;
2714
- }
2715
-
2716
- /**
2717
- * Bridges between ViewBehaviors and HostBehaviors, enabling a host to
2718
- * control ViewBehaviors.
2719
- * @public
2720
- */
2721
- export declare interface ViewBehaviorOrchestrator<TSource = any, TParent = any> extends ViewController<TSource, TParent>, HostBehavior<TSource> {
2722
- /**
2723
- *
2724
- * @param nodeId - The structural id of the DOM node to which a behavior will apply.
2725
- * @param target - The DOM node associated with the id.
2726
- */
2727
- addTarget(nodeId: string, target: Node): void;
2762
+ targetTagName?: string | null;
2728
2763
  /**
2729
- * Adds a behavior.
2730
- * @param behavior - The behavior to add.
2764
+ * The policy that the created behavior must run under.
2731
2765
  */
2732
- addBehavior(behavior: ViewBehavior): void;
2766
+ policy?: DOMPolicy;
2733
2767
  /**
2734
- * Adds a behavior factory.
2735
- * @param factory - The behavior factory to add.
2736
- * @param target - The target the factory will create behaviors for.
2768
+ * Creates a behavior.
2737
2769
  */
2738
- addBehaviorFactory(factory: ViewBehaviorFactory, target: Node): void;
2770
+ createBehavior(): ViewBehavior;
2739
2771
  }
2740
2772
 
2741
- /**
2742
- * Bridges between ViewBehaviors and HostBehaviors, enabling a host to
2743
- * control ViewBehaviors.
2744
- * @public
2745
- */
2746
- export declare const ViewBehaviorOrchestrator: Readonly<{
2747
- /**
2748
- * Creates a ViewBehaviorOrchestrator.
2749
- * @param source - The source to to associate behaviors with.
2750
- * @returns A ViewBehaviorOrchestrator.
2751
- */
2752
- create<TSource = any, TParent = any>(source: TSource): ViewBehaviorOrchestrator<TSource, TParent>;
2753
- }>;
2754
-
2755
2773
  /**
2756
2774
  * The target nodes available to a behavior.
2757
2775
  * @public
@@ -2776,6 +2794,7 @@ export declare interface ViewController<TSource = any, TParent = any> extends Ex
2776
2794
  * @public
2777
2795
  */
2778
2796
  export declare class ViewTemplate<TSource = any, TParent = any> implements ElementViewTemplate<TSource, TParent>, SyntheticViewTemplate<TSource, TParent> {
2797
+ private policy?;
2779
2798
  private result;
2780
2799
  /**
2781
2800
  * The html representing what this template will
@@ -2790,13 +2809,23 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
2790
2809
  * Creates an instance of ViewTemplate.
2791
2810
  * @param html - The html representing what this template will instantiate, including placeholders for directives.
2792
2811
  * @param factories - The directives that will be connected to placeholders in the html.
2812
+ * @param policy - The security policy to use when compiling this template.
2793
2813
  */
2794
- constructor(html: string | HTMLTemplateElement, factories: Record<string, ViewBehaviorFactory>);
2814
+ constructor(html: string | HTMLTemplateElement, factories?: Record<string, ViewBehaviorFactory>, policy?: DOMPolicy | undefined);
2795
2815
  /**
2796
2816
  * Creates an HTMLView instance based on this template definition.
2797
2817
  * @param hostBindingTarget - The element that host behaviors will be bound to.
2798
2818
  */
2799
2819
  create(hostBindingTarget?: Element): HTMLView<TSource, TParent>;
2820
+ /**
2821
+ * Sets the DOMPolicy for this template.
2822
+ * @param policy - The policy to associated with this template.
2823
+ * @returns The modified template instance.
2824
+ * @remarks
2825
+ * The DOMPolicy can only be set once for a template and cannot be
2826
+ * set after the template is compiled.
2827
+ */
2828
+ withPolicy(policy: DOMPolicy): this;
2800
2829
  /**
2801
2830
  * Creates an HTMLView from this template, binds it to the source, and then appends it to the host.
2802
2831
  * @param source - The data source to bind the template to.
@@ -2810,6 +2839,20 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
2810
2839
  * @internal
2811
2840
  */
2812
2841
  toJSON: () => undefined;
2842
+ /**
2843
+ * Creates a template based on a set of static strings and dynamic values.
2844
+ * @param strings - The static strings to create the template with.
2845
+ * @param values - The dynamic values to create the template with.
2846
+ * @param policy - The DOMPolicy to associated with the template.
2847
+ * @returns A ViewTemplate.
2848
+ * @remarks
2849
+ * This API should not be used directly under normal circumstances because constructing
2850
+ * a template in this way, if not done properly, can open up the application to XSS
2851
+ * attacks. When using this API, provide a strong DOMPolicy that can properly sanitize
2852
+ * and also be sure to manually sanitize all static strings particularly if they can
2853
+ * come from user input.
2854
+ */
2855
+ static create<TSource = any, TParent = any>(strings: string[], values: TemplateValue<TSource, TParent>[], policy?: DOMPolicy): ViewTemplate<TSource, TParent>;
2813
2856
  }
2814
2857
 
2815
2858
  /**