@microsoft/fast-element 2.0.0-beta.17 → 2.0.0-beta.19
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/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 +24 -31
- 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 +50 -119
- 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 +39 -13
- package/dist/dts/templating/view.d.ts +2 -2
- package/dist/dts/utilities.d.ts +39 -0
- package/dist/esm/components/attributes.js +1 -1
- package/dist/esm/components/fast-definitions.js +2 -2
- 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/interfaces.js +45 -0
- package/dist/esm/observation/observable.js +3 -3
- package/dist/esm/observation/update-queue.js +2 -2
- package/dist/esm/platform.js +1 -1
- package/dist/esm/polyfills.js +3 -7
- package/dist/esm/templating/binding-signal.js +3 -2
- package/dist/esm/templating/binding-two-way.js +3 -2
- package/dist/esm/templating/binding.js +31 -54
- package/dist/esm/templating/compiler.js +31 -38
- package/dist/esm/templating/dangerous-html.js +23 -0
- package/dist/esm/templating/html-directive.js +38 -135
- 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 +81 -56
- 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 +190 -147
- package/dist/fast-element.debug.js +756 -388
- package/dist/fast-element.debug.min.js +1 -1
- package/dist/fast-element.js +727 -362
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +190 -147
- package/docs/api-report.md +66 -56
- package/package.json +5 -1
- package/dist/dts/templating/dom.d.ts +0 -41
- package/dist/esm/templating/dom.js +0 -49
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { DOMAspect } from "./dom.js";
|
|
2
|
+
import { isString } from "./interfaces.js";
|
|
3
|
+
function safeURL(tagName, aspect, aspectName, sink) {
|
|
4
|
+
return (target, name, value, ...rest) => {
|
|
5
|
+
if (isString(value)) {
|
|
6
|
+
value = value.replace("javascript:", "");
|
|
7
|
+
}
|
|
8
|
+
sink(target, name, value, ...rest);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function block(tagName, aspect, aspectName, sink) {
|
|
12
|
+
throw new Error(`${aspectName} on ${tagName !== null && tagName !== void 0 ? tagName : "text"} is blocked by the current DOMPolicy.`);
|
|
13
|
+
}
|
|
14
|
+
const defaultDOMElementGuards = {
|
|
15
|
+
a: {
|
|
16
|
+
[DOMAspect.attribute]: {
|
|
17
|
+
href: safeURL,
|
|
18
|
+
},
|
|
19
|
+
[DOMAspect.property]: {
|
|
20
|
+
href: safeURL,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
area: {
|
|
24
|
+
[DOMAspect.attribute]: {
|
|
25
|
+
href: safeURL,
|
|
26
|
+
},
|
|
27
|
+
[DOMAspect.property]: {
|
|
28
|
+
href: safeURL,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
button: {
|
|
32
|
+
[DOMAspect.attribute]: {
|
|
33
|
+
formaction: safeURL,
|
|
34
|
+
},
|
|
35
|
+
[DOMAspect.property]: {
|
|
36
|
+
formAction: safeURL,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
embed: {
|
|
40
|
+
[DOMAspect.attribute]: {
|
|
41
|
+
src: block,
|
|
42
|
+
},
|
|
43
|
+
[DOMAspect.property]: {
|
|
44
|
+
src: block,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
form: {
|
|
48
|
+
[DOMAspect.attribute]: {
|
|
49
|
+
action: safeURL,
|
|
50
|
+
},
|
|
51
|
+
[DOMAspect.property]: {
|
|
52
|
+
action: safeURL,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
frame: {
|
|
56
|
+
[DOMAspect.attribute]: {
|
|
57
|
+
src: safeURL,
|
|
58
|
+
},
|
|
59
|
+
[DOMAspect.property]: {
|
|
60
|
+
src: safeURL,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
iframe: {
|
|
64
|
+
[DOMAspect.attribute]: {
|
|
65
|
+
src: safeURL,
|
|
66
|
+
},
|
|
67
|
+
[DOMAspect.property]: {
|
|
68
|
+
src: safeURL,
|
|
69
|
+
srcdoc: block,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
input: {
|
|
73
|
+
[DOMAspect.attribute]: {
|
|
74
|
+
formaction: safeURL,
|
|
75
|
+
},
|
|
76
|
+
[DOMAspect.property]: {
|
|
77
|
+
formAction: safeURL,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
link: {
|
|
81
|
+
[DOMAspect.attribute]: {
|
|
82
|
+
href: block,
|
|
83
|
+
},
|
|
84
|
+
[DOMAspect.property]: {
|
|
85
|
+
href: block,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
object: {
|
|
89
|
+
[DOMAspect.attribute]: {
|
|
90
|
+
codebase: block,
|
|
91
|
+
data: block,
|
|
92
|
+
},
|
|
93
|
+
[DOMAspect.property]: {
|
|
94
|
+
codeBase: block,
|
|
95
|
+
data: block,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
script: {
|
|
99
|
+
[DOMAspect.attribute]: {
|
|
100
|
+
src: block,
|
|
101
|
+
text: block,
|
|
102
|
+
},
|
|
103
|
+
[DOMAspect.property]: {
|
|
104
|
+
src: block,
|
|
105
|
+
text: block,
|
|
106
|
+
innerText: block,
|
|
107
|
+
textContent: block,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
style: {
|
|
111
|
+
[DOMAspect.property]: {
|
|
112
|
+
innerText: block,
|
|
113
|
+
textContent: block,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
const blockedEvents = {
|
|
118
|
+
onabort: block,
|
|
119
|
+
onauxclick: block,
|
|
120
|
+
onbeforeinput: block,
|
|
121
|
+
onbeforematch: block,
|
|
122
|
+
onblur: block,
|
|
123
|
+
oncancel: block,
|
|
124
|
+
oncanplay: block,
|
|
125
|
+
oncanplaythrough: block,
|
|
126
|
+
onchange: block,
|
|
127
|
+
onclick: block,
|
|
128
|
+
onclose: block,
|
|
129
|
+
oncontextlost: block,
|
|
130
|
+
oncontextmenu: block,
|
|
131
|
+
oncontextrestored: block,
|
|
132
|
+
oncopy: block,
|
|
133
|
+
oncuechange: block,
|
|
134
|
+
oncut: block,
|
|
135
|
+
ondblclick: block,
|
|
136
|
+
ondrag: block,
|
|
137
|
+
ondragend: block,
|
|
138
|
+
ondragenter: block,
|
|
139
|
+
ondragleave: block,
|
|
140
|
+
ondragover: block,
|
|
141
|
+
ondragstart: block,
|
|
142
|
+
ondrop: block,
|
|
143
|
+
ondurationchange: block,
|
|
144
|
+
onemptied: block,
|
|
145
|
+
onended: block,
|
|
146
|
+
onerror: block,
|
|
147
|
+
onfocus: block,
|
|
148
|
+
onformdata: block,
|
|
149
|
+
oninput: block,
|
|
150
|
+
oninvalid: block,
|
|
151
|
+
onkeydown: block,
|
|
152
|
+
onkeypress: block,
|
|
153
|
+
onkeyup: block,
|
|
154
|
+
onload: block,
|
|
155
|
+
onloadeddata: block,
|
|
156
|
+
onloadedmetadata: block,
|
|
157
|
+
onloadstart: block,
|
|
158
|
+
onmousedown: block,
|
|
159
|
+
onmouseenter: block,
|
|
160
|
+
onmouseleave: block,
|
|
161
|
+
onmousemove: block,
|
|
162
|
+
onmouseout: block,
|
|
163
|
+
onmouseover: block,
|
|
164
|
+
onmouseup: block,
|
|
165
|
+
onpaste: block,
|
|
166
|
+
onpause: block,
|
|
167
|
+
onplay: block,
|
|
168
|
+
onplaying: block,
|
|
169
|
+
onprogress: block,
|
|
170
|
+
onratechange: block,
|
|
171
|
+
onreset: block,
|
|
172
|
+
onresize: block,
|
|
173
|
+
onscroll: block,
|
|
174
|
+
onsecuritypolicyviolation: block,
|
|
175
|
+
onseeked: block,
|
|
176
|
+
onseeking: block,
|
|
177
|
+
onselect: block,
|
|
178
|
+
onslotchange: block,
|
|
179
|
+
onstalled: block,
|
|
180
|
+
onsubmit: block,
|
|
181
|
+
onsuspend: block,
|
|
182
|
+
ontimeupdate: block,
|
|
183
|
+
ontoggle: block,
|
|
184
|
+
onvolumechange: block,
|
|
185
|
+
onwaiting: block,
|
|
186
|
+
onwebkitanimationend: block,
|
|
187
|
+
onwebkitanimationiteration: block,
|
|
188
|
+
onwebkitanimationstart: block,
|
|
189
|
+
onwebkittransitionend: block,
|
|
190
|
+
onwheel: block,
|
|
191
|
+
};
|
|
192
|
+
const defaultDOMGuards = {
|
|
193
|
+
elements: defaultDOMElementGuards,
|
|
194
|
+
aspects: {
|
|
195
|
+
[DOMAspect.attribute]: Object.assign({}, blockedEvents),
|
|
196
|
+
[DOMAspect.property]: Object.assign({ innerHTML: block }, blockedEvents),
|
|
197
|
+
[DOMAspect.event]: Object.assign({}, blockedEvents),
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
function createDomSinkGuards(config, defaults) {
|
|
201
|
+
const result = {};
|
|
202
|
+
for (const name in defaults) {
|
|
203
|
+
const overrideValue = config[name];
|
|
204
|
+
const defaultValue = defaults[name];
|
|
205
|
+
switch (overrideValue) {
|
|
206
|
+
case null:
|
|
207
|
+
// remove the default
|
|
208
|
+
break;
|
|
209
|
+
case undefined:
|
|
210
|
+
// keep the default
|
|
211
|
+
result[name] = defaultValue;
|
|
212
|
+
break;
|
|
213
|
+
default:
|
|
214
|
+
// override the default
|
|
215
|
+
result[name] = overrideValue;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// add any new sinks that were not overrides
|
|
220
|
+
for (const name in config) {
|
|
221
|
+
if (!(name in result)) {
|
|
222
|
+
result[name] = config[name];
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return Object.freeze(result);
|
|
226
|
+
}
|
|
227
|
+
function createDOMAspectGuards(config, defaults) {
|
|
228
|
+
const result = {};
|
|
229
|
+
for (const aspect in defaults) {
|
|
230
|
+
const overrideValue = config[aspect];
|
|
231
|
+
const defaultValue = defaults[aspect];
|
|
232
|
+
switch (overrideValue) {
|
|
233
|
+
case null:
|
|
234
|
+
// remove the default
|
|
235
|
+
break;
|
|
236
|
+
case undefined:
|
|
237
|
+
// keep the default
|
|
238
|
+
result[aspect] = createDomSinkGuards(defaultValue, {});
|
|
239
|
+
break;
|
|
240
|
+
default:
|
|
241
|
+
// override the default
|
|
242
|
+
result[aspect] = createDomSinkGuards(overrideValue, defaultValue);
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
// add any new aspect guards that were not overrides
|
|
247
|
+
for (const aspect in config) {
|
|
248
|
+
if (!(aspect in result)) {
|
|
249
|
+
result[aspect] = createDomSinkGuards(config[aspect], {});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return Object.freeze(result);
|
|
253
|
+
}
|
|
254
|
+
function createElementGuards(config, defaults) {
|
|
255
|
+
const result = {};
|
|
256
|
+
for (const tag in defaults) {
|
|
257
|
+
const overrideValue = config[tag];
|
|
258
|
+
const defaultValue = defaults[tag];
|
|
259
|
+
switch (overrideValue) {
|
|
260
|
+
case null:
|
|
261
|
+
// remove the default
|
|
262
|
+
break;
|
|
263
|
+
case undefined:
|
|
264
|
+
// keep the default
|
|
265
|
+
result[tag] = createDOMAspectGuards(overrideValue, {});
|
|
266
|
+
break;
|
|
267
|
+
default:
|
|
268
|
+
// override the default aspects
|
|
269
|
+
result[tag] = createDOMAspectGuards(overrideValue, defaultValue);
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
// Add any new element guards that were not overrides
|
|
274
|
+
for (const tag in config) {
|
|
275
|
+
if (!(tag in result)) {
|
|
276
|
+
result[tag] = createDOMAspectGuards(config[tag], {});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return Object.freeze(result);
|
|
280
|
+
}
|
|
281
|
+
function createDOMGuards(config, defaults) {
|
|
282
|
+
return Object.freeze({
|
|
283
|
+
elements: config.elements
|
|
284
|
+
? createElementGuards(config.elements, defaults.elements)
|
|
285
|
+
: defaults.elements,
|
|
286
|
+
aspects: config.aspects
|
|
287
|
+
? createDOMAspectGuards(config.aspects, defaults.aspects)
|
|
288
|
+
: defaults.aspects,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
function createTrustedType() {
|
|
292
|
+
const createHTML = html => html;
|
|
293
|
+
return globalThis.trustedTypes
|
|
294
|
+
? globalThis.trustedTypes.createPolicy("fast-html", { createHTML })
|
|
295
|
+
: { createHTML };
|
|
296
|
+
}
|
|
297
|
+
function tryGuard(aspectGuards, tagName, aspect, aspectName, sink) {
|
|
298
|
+
const sinkGuards = aspectGuards[aspect];
|
|
299
|
+
if (sinkGuards) {
|
|
300
|
+
const guard = sinkGuards[aspectName];
|
|
301
|
+
if (guard) {
|
|
302
|
+
return guard(tagName, aspect, aspectName, sink);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
const DOMPolicy = Object.freeze({
|
|
307
|
+
/**
|
|
308
|
+
* Creates a new DOM Policy object.
|
|
309
|
+
* @param options The options to use in creating the policy.
|
|
310
|
+
* @returns The newly created DOMPolicy.
|
|
311
|
+
*/
|
|
312
|
+
create(options = {}) {
|
|
313
|
+
var _a, _b;
|
|
314
|
+
const trustedType = (_a = options.trustedType) !== null && _a !== void 0 ? _a : createTrustedType();
|
|
315
|
+
const guards = createDOMGuards((_b = options.guards) !== null && _b !== void 0 ? _b : {}, defaultDOMGuards);
|
|
316
|
+
return Object.freeze({
|
|
317
|
+
createHTML(value) {
|
|
318
|
+
return trustedType.createHTML(value);
|
|
319
|
+
},
|
|
320
|
+
protect(tagName, aspect, aspectName, sink) {
|
|
321
|
+
var _a;
|
|
322
|
+
// Check for element-specific guards.
|
|
323
|
+
const key = (tagName !== null && tagName !== void 0 ? tagName : "").toLowerCase();
|
|
324
|
+
const elementGuards = guards.elements[key];
|
|
325
|
+
if (elementGuards) {
|
|
326
|
+
const guard = tryGuard(elementGuards, tagName, aspect, aspectName, sink);
|
|
327
|
+
if (guard) {
|
|
328
|
+
return guard;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
// Check for guards applicable to all nodes.
|
|
332
|
+
return ((_a = tryGuard(guards.aspects, tagName, aspect, aspectName, sink)) !== null && _a !== void 0 ? _a : sink);
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
},
|
|
336
|
+
});
|
|
337
|
+
export { DOMPolicy };
|
package/dist/esm/dom.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Updates } from "./observation/update-queue.js";
|
|
2
|
+
import "./interfaces.js";
|
|
3
|
+
import { FAST } from "./platform.js";
|
|
4
|
+
/**
|
|
5
|
+
* The type of HTML aspect to target.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export const DOMAspect = Object.freeze({
|
|
9
|
+
/**
|
|
10
|
+
* Not aspected.
|
|
11
|
+
*/
|
|
12
|
+
none: 0,
|
|
13
|
+
/**
|
|
14
|
+
* An attribute.
|
|
15
|
+
*/
|
|
16
|
+
attribute: 1,
|
|
17
|
+
/**
|
|
18
|
+
* A boolean attribute.
|
|
19
|
+
*/
|
|
20
|
+
booleanAttribute: 2,
|
|
21
|
+
/**
|
|
22
|
+
* A property.
|
|
23
|
+
*/
|
|
24
|
+
property: 3,
|
|
25
|
+
/**
|
|
26
|
+
* Content
|
|
27
|
+
*/
|
|
28
|
+
content: 4,
|
|
29
|
+
/**
|
|
30
|
+
* A token list.
|
|
31
|
+
*/
|
|
32
|
+
tokenList: 5,
|
|
33
|
+
/**
|
|
34
|
+
* An event.
|
|
35
|
+
*/
|
|
36
|
+
event: 6,
|
|
37
|
+
});
|
|
38
|
+
const createHTML = html => html;
|
|
39
|
+
const fastTrustedType = globalThis.trustedTypes
|
|
40
|
+
? globalThis.trustedTypes.createPolicy("fast-html", { createHTML })
|
|
41
|
+
: { createHTML };
|
|
42
|
+
let defaultPolicy = Object.freeze({
|
|
43
|
+
createHTML(value) {
|
|
44
|
+
return fastTrustedType.createHTML(value);
|
|
45
|
+
},
|
|
46
|
+
protect(tagName, aspect, aspectName, sink) {
|
|
47
|
+
return sink;
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
const fastPolicy = defaultPolicy;
|
|
51
|
+
/**
|
|
52
|
+
* Common DOM APIs.
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export const DOM = Object.freeze({
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated
|
|
58
|
+
* Use Updates.enqueue().
|
|
59
|
+
*/
|
|
60
|
+
queueUpdate: Updates.enqueue,
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated
|
|
63
|
+
* Use Updates.next()
|
|
64
|
+
*/
|
|
65
|
+
nextUpdate: Updates.next,
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated
|
|
68
|
+
* Use Updates.process()
|
|
69
|
+
*/
|
|
70
|
+
processUpdates: Updates.process,
|
|
71
|
+
/**
|
|
72
|
+
* Gets the dom policy used by the templating system.
|
|
73
|
+
*/
|
|
74
|
+
get policy() {
|
|
75
|
+
return defaultPolicy;
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* Sets the dom policy used by the templating system.
|
|
79
|
+
* @param policy - The policy to set.
|
|
80
|
+
* @remarks
|
|
81
|
+
* This API can only be called once, for security reasons. It should be
|
|
82
|
+
* called by the application developer at the start of their program.
|
|
83
|
+
*/
|
|
84
|
+
setPolicy(value) {
|
|
85
|
+
if (defaultPolicy !== fastPolicy) {
|
|
86
|
+
throw FAST.error(1201 /* Message.onlySetDOMPolicyOnce */);
|
|
87
|
+
}
|
|
88
|
+
defaultPolicy = value;
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* Sets an attribute value on an element.
|
|
92
|
+
* @param element - The element to set the attribute value on.
|
|
93
|
+
* @param attributeName - The attribute name to set.
|
|
94
|
+
* @param value - The value of the attribute to set.
|
|
95
|
+
* @remarks
|
|
96
|
+
* If the value is `null` or `undefined`, the attribute is removed, otherwise
|
|
97
|
+
* it is set to the provided value using the standard `setAttribute` API.
|
|
98
|
+
*/
|
|
99
|
+
setAttribute(element, attributeName, value) {
|
|
100
|
+
value === null || value === undefined
|
|
101
|
+
? element.removeAttribute(attributeName)
|
|
102
|
+
: element.setAttribute(attributeName, value);
|
|
103
|
+
},
|
|
104
|
+
/**
|
|
105
|
+
* Sets a boolean attribute value.
|
|
106
|
+
* @param element - The element to set the boolean attribute value on.
|
|
107
|
+
* @param attributeName - The attribute name to set.
|
|
108
|
+
* @param value - The value of the attribute to set.
|
|
109
|
+
* @remarks
|
|
110
|
+
* If the value is true, the attribute is added; otherwise it is removed.
|
|
111
|
+
*/
|
|
112
|
+
setBooleanAttribute(element, attributeName, value) {
|
|
113
|
+
value
|
|
114
|
+
? element.setAttribute(attributeName, "")
|
|
115
|
+
: element.removeAttribute(attributeName);
|
|
116
|
+
},
|
|
117
|
+
});
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from "./platform.js";
|
|
2
|
+
export * from "./dom.js";
|
|
2
3
|
// Observation
|
|
3
4
|
export * from "./observation/observable.js";
|
|
4
5
|
export * from "./observation/notifier.js";
|
|
@@ -10,7 +11,6 @@ export * from "./styles/css.js";
|
|
|
10
11
|
export * from "./styles/css-directive.js";
|
|
11
12
|
export * from "./styles/host.js";
|
|
12
13
|
// Templating
|
|
13
|
-
export * from "./templating/dom.js";
|
|
14
14
|
export * from "./templating/template.js";
|
|
15
15
|
export * from "./templating/compiler.js";
|
|
16
16
|
export { Markup, Parser } from "./templating/markup.js";
|
|
@@ -23,6 +23,7 @@ export * from "./templating/slotted.js";
|
|
|
23
23
|
export * from "./templating/children.js";
|
|
24
24
|
export * from "./templating/view.js";
|
|
25
25
|
export * from "./templating/node-observation.js";
|
|
26
|
+
export * from "./templating/dangerous-html.js";
|
|
26
27
|
// Components
|
|
27
28
|
export * from "./components/fast-element.js";
|
|
28
29
|
export * from "./components/fast-definitions.js";
|
package/dist/esm/index.rollup.js
CHANGED
package/dist/esm/interfaces.js
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
+
let kernelMode;
|
|
2
|
+
const kernelAttr = "fast-kernel";
|
|
3
|
+
try {
|
|
4
|
+
if (document.currentScript) {
|
|
5
|
+
kernelMode = document.currentScript.getAttribute(kernelAttr);
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
const scripts = document.getElementsByTagName("script");
|
|
9
|
+
const currentScript = scripts[scripts.length - 1];
|
|
10
|
+
kernelMode = currentScript.getAttribute(kernelAttr);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
kernelMode = "isolate";
|
|
15
|
+
}
|
|
16
|
+
let KernelServiceId;
|
|
17
|
+
switch (kernelMode) {
|
|
18
|
+
case "share": // share the kernel across major versions
|
|
19
|
+
KernelServiceId = Object.freeze({
|
|
20
|
+
updateQueue: 1,
|
|
21
|
+
observable: 2,
|
|
22
|
+
contextEvent: 3,
|
|
23
|
+
elementRegistry: 4,
|
|
24
|
+
});
|
|
25
|
+
break;
|
|
26
|
+
case "share-v2": // only share the kernel with other v2 instances
|
|
27
|
+
KernelServiceId = Object.freeze({
|
|
28
|
+
updateQueue: 1.2,
|
|
29
|
+
observable: 2.2,
|
|
30
|
+
contextEvent: 3.2,
|
|
31
|
+
elementRegistry: 4.2,
|
|
32
|
+
});
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
// fully isolate the kernel from all other FAST instances
|
|
36
|
+
const postfix = `-${Math.random().toString(36).substring(2, 8)}`;
|
|
37
|
+
KernelServiceId = Object.freeze({
|
|
38
|
+
updateQueue: `1.2${postfix}`,
|
|
39
|
+
observable: `2.2${postfix}`,
|
|
40
|
+
contextEvent: `3.2${postfix}`,
|
|
41
|
+
elementRegistry: `4.2${postfix}`,
|
|
42
|
+
});
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
export { KernelServiceId };
|
|
1
46
|
/**
|
|
2
47
|
* @internal
|
|
3
48
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isFunction, isString, noop, } from "../interfaces.js";
|
|
1
|
+
import { isFunction, isString, KernelServiceId, noop, } from "../interfaces.js";
|
|
2
2
|
import { createMetadataLocator, FAST } from "../platform.js";
|
|
3
3
|
import { Updates } from "./update-queue.js";
|
|
4
4
|
import { PropertyChangeNotifier, SubscriberSet } from "./notifier.js";
|
|
@@ -21,7 +21,7 @@ export const SourceLifetime = Object.freeze({
|
|
|
21
21
|
* Common Observable APIs.
|
|
22
22
|
* @public
|
|
23
23
|
*/
|
|
24
|
-
export const Observable = FAST.getById(
|
|
24
|
+
export const Observable = FAST.getById(KernelServiceId.observable, () => {
|
|
25
25
|
const queueUpdate = Updates.enqueue;
|
|
26
26
|
const volatileRegex = /(:|&&|\|\||if)/;
|
|
27
27
|
const notifierLookup = new WeakMap();
|
|
@@ -292,7 +292,7 @@ export function volatile(target, name, descriptor) {
|
|
|
292
292
|
},
|
|
293
293
|
});
|
|
294
294
|
}
|
|
295
|
-
const contextEvent = FAST.getById(
|
|
295
|
+
const contextEvent = FAST.getById(KernelServiceId.contextEvent, () => {
|
|
296
296
|
let current = null;
|
|
297
297
|
return {
|
|
298
298
|
get() {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "../interfaces.js";
|
|
1
|
+
import { KernelServiceId } from "../interfaces.js";
|
|
2
2
|
import { FAST } from "../platform.js";
|
|
3
3
|
/**
|
|
4
4
|
* The default UpdateQueue.
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export const Updates = FAST.getById(
|
|
7
|
+
export const Updates = FAST.getById(KernelServiceId.updateQueue, () => {
|
|
8
8
|
const tasks = [];
|
|
9
9
|
const pendingErrors = [];
|
|
10
10
|
const rAF = globalThis.requestAnimationFrame;
|
package/dist/esm/platform.js
CHANGED
package/dist/esm/polyfills.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
1
2
|
(function ensureGlobalThis() {
|
|
2
3
|
if (typeof globalThis !== "undefined") {
|
|
3
4
|
// We're running in a modern environment.
|
|
4
5
|
return;
|
|
5
6
|
}
|
|
7
|
+
// @ts-ignore
|
|
6
8
|
if (typeof global !== "undefined") {
|
|
7
9
|
// We're running in NodeJS
|
|
10
|
+
// @ts-ignore
|
|
8
11
|
global.globalThis = global;
|
|
9
12
|
}
|
|
10
13
|
else if (typeof self !== "undefined") {
|
|
@@ -22,10 +25,3 @@
|
|
|
22
25
|
result.globalThis = result;
|
|
23
26
|
}
|
|
24
27
|
})();
|
|
25
|
-
// API-only Polyfill for trustedTypes
|
|
26
|
-
if (!globalThis.trustedTypes) {
|
|
27
|
-
globalThis.trustedTypes = {
|
|
28
|
-
createPolicy: (n, r) => r,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export {};
|
|
@@ -78,11 +78,12 @@ class SignalBinding extends Binding {
|
|
|
78
78
|
* Creates a signal binding configuration with the supplied options.
|
|
79
79
|
* @param expression - The binding to refresh when signaled.
|
|
80
80
|
* @param options - The signal name or a binding to use to retrieve the signal name.
|
|
81
|
+
* @param policy - The security policy to associate with th binding.
|
|
81
82
|
* @returns A binding configuration.
|
|
82
83
|
* @public
|
|
83
84
|
*/
|
|
84
|
-
export function signal(expression, options) {
|
|
85
|
-
const binding = new SignalBinding(expression);
|
|
85
|
+
export function signal(expression, options, policy) {
|
|
86
|
+
const binding = new SignalBinding(expression, policy);
|
|
86
87
|
binding.options = options;
|
|
87
88
|
return binding;
|
|
88
89
|
}
|
|
@@ -88,11 +88,12 @@ class TwoWayBinding extends Binding {
|
|
|
88
88
|
* Creates a default binding.
|
|
89
89
|
* @param expression - The binding to refresh when changed.
|
|
90
90
|
* @param optionsOrChangeEvent - The binding options or the name of the change event to use.
|
|
91
|
+
* @param policy - The security policy to associate with the binding.
|
|
91
92
|
* @param isBindingVolatile - Indicates whether the binding is volatile or not.
|
|
92
93
|
* @returns A binding.
|
|
93
94
|
* @public
|
|
94
95
|
*/
|
|
95
|
-
export function twoWay(expression, optionsOrChangeEvent, isBindingVolatile = Observable.isVolatileBinding(expression)) {
|
|
96
|
+
export function twoWay(expression, optionsOrChangeEvent, policy, isBindingVolatile = Observable.isVolatileBinding(expression)) {
|
|
96
97
|
if (isString(optionsOrChangeEvent)) {
|
|
97
98
|
optionsOrChangeEvent = { changeEvent: optionsOrChangeEvent };
|
|
98
99
|
}
|
|
@@ -102,7 +103,7 @@ export function twoWay(expression, optionsOrChangeEvent, isBindingVolatile = Obs
|
|
|
102
103
|
else if (!optionsOrChangeEvent.fromView) {
|
|
103
104
|
optionsOrChangeEvent.fromView = defaultOptions.fromView;
|
|
104
105
|
}
|
|
105
|
-
const binding = new TwoWayBinding(expression, isBindingVolatile);
|
|
106
|
+
const binding = new TwoWayBinding(expression, policy, isBindingVolatile);
|
|
106
107
|
binding.options = optionsOrChangeEvent;
|
|
107
108
|
return binding;
|
|
108
109
|
}
|