@microsoft/fast-element 2.0.0-beta.16 → 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.
- package/CHANGELOG.json +36 -0
- package/CHANGELOG.md +18 -1
- package/dist/dts/components/element-controller.d.ts +5 -0
- package/dist/dts/dom-policy.d.ts +68 -0
- package/dist/dts/dom.d.ts +116 -0
- package/dist/dts/index.d.ts +3 -2
- package/dist/dts/index.rollup.d.ts +0 -1
- package/dist/dts/index.rollup.debug.d.ts +0 -1
- package/dist/dts/interfaces.d.ts +15 -24
- package/dist/dts/polyfills.d.ts +0 -1
- package/dist/dts/templating/binding-signal.d.ts +3 -1
- package/dist/dts/templating/binding-two-way.d.ts +3 -1
- package/dist/dts/templating/binding.d.ts +16 -5
- package/dist/dts/templating/compiler.d.ts +11 -13
- package/dist/dts/templating/dangerous-html.d.ts +18 -0
- package/dist/dts/templating/html-directive.d.ts +54 -118
- package/dist/dts/templating/node-observation.d.ts +11 -1
- package/dist/dts/templating/ref.d.ts +4 -0
- package/dist/dts/templating/render.d.ts +30 -6
- package/dist/dts/templating/repeat.d.ts +1 -5
- package/dist/dts/templating/template.d.ts +44 -13
- package/dist/dts/templating/view.d.ts +8 -3
- package/dist/dts/testing/fakes.d.ts +1 -0
- package/dist/dts/utilities.d.ts +39 -0
- package/dist/esm/components/attributes.js +1 -1
- package/dist/esm/components/element-controller.js +6 -1
- package/dist/esm/debug.js +4 -1
- package/dist/esm/dom-policy.js +337 -0
- package/dist/esm/dom.js +117 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.rollup.debug.js +3 -1
- package/dist/esm/index.rollup.js +3 -1
- package/dist/esm/observation/observable.js +5 -1
- package/dist/esm/platform.js +1 -1
- package/dist/esm/polyfills.js +3 -7
- package/dist/esm/templating/binding-signal.js +9 -3
- package/dist/esm/templating/binding-two-way.js +9 -3
- package/dist/esm/templating/binding.js +40 -55
- package/dist/esm/templating/children.js +8 -4
- package/dist/esm/templating/compiler.js +31 -38
- package/dist/esm/templating/dangerous-html.js +23 -0
- package/dist/esm/templating/html-directive.js +42 -133
- package/dist/esm/templating/node-observation.js +14 -8
- package/dist/esm/templating/ref.js +1 -1
- package/dist/esm/templating/render.js +17 -6
- package/dist/esm/templating/repeat.js +2 -6
- package/dist/esm/templating/template.js +86 -56
- package/dist/esm/templating/view.js +6 -0
- package/dist/esm/testing/fakes.js +2 -0
- package/dist/esm/testing/fixture.js +1 -1
- package/dist/esm/utilities.js +68 -0
- package/dist/fast-element.api.json +1088 -608
- package/dist/fast-element.d.ts +194 -147
- package/dist/fast-element.debug.js +745 -381
- package/dist/fast-element.debug.min.js +1 -1
- package/dist/fast-element.js +716 -355
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +208 -145
- package/docs/api-report.md +74 -56
- package/package.json +5 -1
- package/yarn-error.log +177 -0
- package/dist/dts/templating/dom.d.ts +0 -41
- 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:
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
@@ -783,6 +838,11 @@ export declare class ElementController<TElement extends HTMLElement = HTMLElemen
|
|
|
783
838
|
* Only emits events if connected.
|
|
784
839
|
*/
|
|
785
840
|
emit(type: string, detail?: any, options?: Omit<CustomEventInit, "detail">): void | boolean;
|
|
841
|
+
/**
|
|
842
|
+
* Opts out of JSON stringification.
|
|
843
|
+
* @internal
|
|
844
|
+
*/
|
|
845
|
+
toJSON: () => undefined;
|
|
786
846
|
private renderTemplate;
|
|
787
847
|
/**
|
|
788
848
|
* Locates or creates a controller for the specified element.
|
|
@@ -1357,7 +1417,15 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
|
|
|
1357
1417
|
/**
|
|
1358
1418
|
* The structural id of the DOM node to which the created behavior will apply.
|
|
1359
1419
|
*/
|
|
1360
|
-
|
|
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;
|
|
1361
1429
|
/**
|
|
1362
1430
|
* The original source aspect exactly as represented in markup.
|
|
1363
1431
|
*/
|
|
@@ -1369,7 +1437,7 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
|
|
|
1369
1437
|
/**
|
|
1370
1438
|
* The type of aspect to target.
|
|
1371
1439
|
*/
|
|
1372
|
-
aspectType:
|
|
1440
|
+
aspectType: DOMAspect;
|
|
1373
1441
|
/**
|
|
1374
1442
|
* Creates an instance of HTMLBindingDirective.
|
|
1375
1443
|
* @param dataBinding - The binding configuration to apply.
|
|
@@ -1427,6 +1495,14 @@ export declare const HTMLDirective: Readonly<{
|
|
|
1427
1495
|
* @param options - Options that specify the directive's application.
|
|
1428
1496
|
*/
|
|
1429
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;
|
|
1430
1506
|
}>;
|
|
1431
1507
|
|
|
1432
1508
|
/**
|
|
@@ -1551,7 +1627,7 @@ export declare class HTMLView<TSource = any, TParent = any> implements ElementVi
|
|
|
1551
1627
|
* @param fragment - The html fragment that contains the nodes for this view.
|
|
1552
1628
|
* @param behaviors - The behaviors to be applied to this view.
|
|
1553
1629
|
*/
|
|
1554
|
-
constructor(fragment: DocumentFragment, factories: ReadonlyArray<
|
|
1630
|
+
constructor(fragment: DocumentFragment, factories: ReadonlyArray<CompiledViewBehaviorFactory>, targets: ViewBehaviorTargets);
|
|
1555
1631
|
/**
|
|
1556
1632
|
* Appends the view's DOM nodes to the referenced node.
|
|
1557
1633
|
* @param node - The parent node to append the view's DOM nodes to.
|
|
@@ -1585,6 +1661,11 @@ export declare class HTMLView<TSource = any, TParent = any> implements ElementVi
|
|
|
1585
1661
|
* Unbinds a view's behaviors from its binding source.
|
|
1586
1662
|
*/
|
|
1587
1663
|
unbind(): void;
|
|
1664
|
+
/**
|
|
1665
|
+
* Opts out of JSON stringification.
|
|
1666
|
+
* @internal
|
|
1667
|
+
*/
|
|
1668
|
+
toJSON: () => undefined;
|
|
1588
1669
|
private evaluateUnbindables;
|
|
1589
1670
|
/**
|
|
1590
1671
|
* Efficiently disposes of a contiguous range of synthetic view instances.
|
|
@@ -1686,7 +1767,17 @@ export declare interface NodeBehaviorOptions<T = any> {
|
|
|
1686
1767
|
* Internally used by the SlottedDirective and the ChildrenDirective.
|
|
1687
1768
|
*/
|
|
1688
1769
|
export declare abstract class NodeObservationDirective<T extends NodeBehaviorOptions> extends StatelessAttachedAttributeDirective<T> {
|
|
1689
|
-
private
|
|
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;
|
|
1690
1781
|
/**
|
|
1691
1782
|
* Bind this behavior to the source.
|
|
1692
1783
|
* @param source - The source to bind to.
|
|
@@ -1877,10 +1968,11 @@ export declare interface ObservationRecord {
|
|
|
1877
1968
|
/**
|
|
1878
1969
|
* Creates a one time binding
|
|
1879
1970
|
* @param expression - The binding to refresh when signaled.
|
|
1971
|
+
* @param policy - The security policy to associate with th binding.
|
|
1880
1972
|
* @returns A binding configuration.
|
|
1881
1973
|
* @public
|
|
1882
1974
|
*/
|
|
1883
|
-
export declare function oneTime<T = any>(expression: Expression<T
|
|
1975
|
+
export declare function oneTime<T = any>(expression: Expression<T>, policy?: DOMPolicy): Binding<T>;
|
|
1884
1976
|
|
|
1885
1977
|
/**
|
|
1886
1978
|
* Common APIs related to content parsing.
|
|
@@ -1998,6 +2090,10 @@ export declare const ref: <TSource = any, TParent = any>(propertyName: keyof TSo
|
|
|
1998
2090
|
* @public
|
|
1999
2091
|
*/
|
|
2000
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;
|
|
2001
2097
|
/**
|
|
2002
2098
|
* Bind this behavior.
|
|
2003
2099
|
* @param controller - The view controller that manages the lifecycle of this behavior.
|
|
@@ -2072,14 +2168,10 @@ export declare class RepeatDirective<TSource = any> implements HTMLDirective, Vi
|
|
|
2072
2168
|
readonly dataBinding: Binding<TSource>;
|
|
2073
2169
|
readonly templateBinding: Binding<TSource, SyntheticViewTemplate>;
|
|
2074
2170
|
readonly options: RepeatOptions;
|
|
2075
|
-
/**
|
|
2076
|
-
* The unique id of the factory.
|
|
2077
|
-
*/
|
|
2078
|
-
id: string;
|
|
2079
2171
|
/**
|
|
2080
2172
|
* The structural id of the DOM node to which the created behavior will apply.
|
|
2081
2173
|
*/
|
|
2082
|
-
|
|
2174
|
+
targetNodeId: string;
|
|
2083
2175
|
/**
|
|
2084
2176
|
* Creates a placeholder string based on the directive's index within the template.
|
|
2085
2177
|
* @param index - The index of the directive within the template.
|
|
@@ -2347,13 +2439,10 @@ export declare type SpliceStrategySupport = typeof SpliceStrategySupport[keyof t
|
|
|
2347
2439
|
export declare abstract class StatelessAttachedAttributeDirective<TOptions> implements HTMLDirective, ViewBehaviorFactory, ViewBehavior {
|
|
2348
2440
|
protected options: TOptions;
|
|
2349
2441
|
/**
|
|
2350
|
-
*
|
|
2351
|
-
|
|
2352
|
-
id: string;
|
|
2353
|
-
/**
|
|
2354
|
-
* The structural id of the DOM node to which the created behavior will apply.
|
|
2442
|
+
* Opts out of JSON stringification.
|
|
2443
|
+
* @internal
|
|
2355
2444
|
*/
|
|
2356
|
-
|
|
2445
|
+
toJSON: () => undefined;
|
|
2357
2446
|
/**
|
|
2358
2447
|
* Creates an instance of RefDirective.
|
|
2359
2448
|
* @param options - The options to use in configuring the directive.
|
|
@@ -2540,31 +2629,6 @@ export declare interface SyntheticViewTemplate<TSource = any, TParent = any> {
|
|
|
2540
2629
|
*/
|
|
2541
2630
|
export declare type TemplateValue<TSource, TParent = any> = Expression<TSource, any, TParent> | Binding<TSource, any, TParent> | HTMLDirective | CaptureType<TSource, TParent>;
|
|
2542
2631
|
|
|
2543
|
-
/**
|
|
2544
|
-
* Enables working with trusted types.
|
|
2545
|
-
* @public
|
|
2546
|
-
*/
|
|
2547
|
-
export declare type TrustedTypes = {
|
|
2548
|
-
/**
|
|
2549
|
-
* Creates a trusted types policy.
|
|
2550
|
-
* @param name - The policy name.
|
|
2551
|
-
* @param rules - The policy rules implementation.
|
|
2552
|
-
*/
|
|
2553
|
-
createPolicy(name: string, rules: TrustedTypesPolicy): TrustedTypesPolicy;
|
|
2554
|
-
};
|
|
2555
|
-
|
|
2556
|
-
/**
|
|
2557
|
-
* A policy for use with the standard trustedTypes platform API.
|
|
2558
|
-
* @public
|
|
2559
|
-
*/
|
|
2560
|
-
export declare type TrustedTypesPolicy = {
|
|
2561
|
-
/**
|
|
2562
|
-
* Creates trusted HTML.
|
|
2563
|
-
* @param html - The HTML to clear as trustworthy.
|
|
2564
|
-
*/
|
|
2565
|
-
createHTML(html: string): string;
|
|
2566
|
-
};
|
|
2567
|
-
|
|
2568
2632
|
/**
|
|
2569
2633
|
* Do not change. Part of shared kernel contract.
|
|
2570
2634
|
* @internal
|
|
@@ -2687,56 +2751,25 @@ export declare interface ViewBehaviorFactory {
|
|
|
2687
2751
|
/**
|
|
2688
2752
|
* The unique id of the factory.
|
|
2689
2753
|
*/
|
|
2690
|
-
id
|
|
2754
|
+
id?: string;
|
|
2691
2755
|
/**
|
|
2692
2756
|
* The structural id of the DOM node to which the created behavior will apply.
|
|
2693
2757
|
*/
|
|
2694
|
-
|
|
2758
|
+
targetNodeId?: string;
|
|
2695
2759
|
/**
|
|
2696
|
-
*
|
|
2760
|
+
* The tag name of the DOM node to which the created behavior will apply.
|
|
2697
2761
|
*/
|
|
2698
|
-
|
|
2699
|
-
}
|
|
2700
|
-
|
|
2701
|
-
/**
|
|
2702
|
-
* Bridges between ViewBehaviors and HostBehaviors, enabling a host to
|
|
2703
|
-
* control ViewBehaviors.
|
|
2704
|
-
* @public
|
|
2705
|
-
*/
|
|
2706
|
-
export declare interface ViewBehaviorOrchestrator<TSource = any, TParent = any> extends ViewController<TSource, TParent>, HostBehavior<TSource> {
|
|
2762
|
+
targetTagName?: string | null;
|
|
2707
2763
|
/**
|
|
2708
|
-
*
|
|
2709
|
-
* @param nodeId - The structural id of the DOM node to which a behavior will apply.
|
|
2710
|
-
* @param target - The DOM node associated with the id.
|
|
2711
|
-
*/
|
|
2712
|
-
addTarget(nodeId: string, target: Node): void;
|
|
2713
|
-
/**
|
|
2714
|
-
* Adds a behavior.
|
|
2715
|
-
* @param behavior - The behavior to add.
|
|
2764
|
+
* The policy that the created behavior must run under.
|
|
2716
2765
|
*/
|
|
2717
|
-
|
|
2766
|
+
policy?: DOMPolicy;
|
|
2718
2767
|
/**
|
|
2719
|
-
*
|
|
2720
|
-
* @param factory - The behavior factory to add.
|
|
2721
|
-
* @param target - The target the factory will create behaviors for.
|
|
2768
|
+
* Creates a behavior.
|
|
2722
2769
|
*/
|
|
2723
|
-
|
|
2770
|
+
createBehavior(): ViewBehavior;
|
|
2724
2771
|
}
|
|
2725
2772
|
|
|
2726
|
-
/**
|
|
2727
|
-
* Bridges between ViewBehaviors and HostBehaviors, enabling a host to
|
|
2728
|
-
* control ViewBehaviors.
|
|
2729
|
-
* @public
|
|
2730
|
-
*/
|
|
2731
|
-
export declare const ViewBehaviorOrchestrator: Readonly<{
|
|
2732
|
-
/**
|
|
2733
|
-
* Creates a ViewBehaviorOrchestrator.
|
|
2734
|
-
* @param source - The source to to associate behaviors with.
|
|
2735
|
-
* @returns A ViewBehaviorOrchestrator.
|
|
2736
|
-
*/
|
|
2737
|
-
create<TSource = any, TParent = any>(source: TSource): ViewBehaviorOrchestrator<TSource, TParent>;
|
|
2738
|
-
}>;
|
|
2739
|
-
|
|
2740
2773
|
/**
|
|
2741
2774
|
* The target nodes available to a behavior.
|
|
2742
2775
|
* @public
|
|
@@ -2761,6 +2794,7 @@ export declare interface ViewController<TSource = any, TParent = any> extends Ex
|
|
|
2761
2794
|
* @public
|
|
2762
2795
|
*/
|
|
2763
2796
|
export declare class ViewTemplate<TSource = any, TParent = any> implements ElementViewTemplate<TSource, TParent>, SyntheticViewTemplate<TSource, TParent> {
|
|
2797
|
+
private policy?;
|
|
2764
2798
|
private result;
|
|
2765
2799
|
/**
|
|
2766
2800
|
* The html representing what this template will
|
|
@@ -2775,13 +2809,23 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
|
|
|
2775
2809
|
* Creates an instance of ViewTemplate.
|
|
2776
2810
|
* @param html - The html representing what this template will instantiate, including placeholders for directives.
|
|
2777
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.
|
|
2778
2813
|
*/
|
|
2779
|
-
constructor(html: string | HTMLTemplateElement, factories
|
|
2814
|
+
constructor(html: string | HTMLTemplateElement, factories?: Record<string, ViewBehaviorFactory>, policy?: DOMPolicy | undefined);
|
|
2780
2815
|
/**
|
|
2781
2816
|
* Creates an HTMLView instance based on this template definition.
|
|
2782
2817
|
* @param hostBindingTarget - The element that host behaviors will be bound to.
|
|
2783
2818
|
*/
|
|
2784
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;
|
|
2785
2829
|
/**
|
|
2786
2830
|
* Creates an HTMLView from this template, binds it to the source, and then appends it to the host.
|
|
2787
2831
|
* @param source - The data source to bind the template to.
|
|
@@ -2790,6 +2834,25 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
|
|
|
2790
2834
|
* host that the template is being attached to.
|
|
2791
2835
|
*/
|
|
2792
2836
|
render(source: TSource, host: Node, hostBindingTarget?: Element): HTMLView<TSource, TParent>;
|
|
2837
|
+
/**
|
|
2838
|
+
* Opts out of JSON stringification.
|
|
2839
|
+
* @internal
|
|
2840
|
+
*/
|
|
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>;
|
|
2793
2856
|
}
|
|
2794
2857
|
|
|
2795
2858
|
/**
|