@microsoft/fast-element 2.9.0 → 2.9.2
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 +31 -1
- package/CHANGELOG.md +18 -2
- package/dist/context/context.api.json +7 -7
- package/dist/di/di.api.json +12 -12
- package/dist/dts/binding/two-way.d.ts +1 -1
- package/dist/dts/components/attributes.d.ts +3 -3
- package/dist/dts/components/fast-definitions.d.ts +1 -1
- package/dist/dts/context.d.ts +7 -7
- package/dist/dts/di/di.d.ts +13 -13
- package/dist/dts/dom-policy.d.ts +5 -5
- package/dist/dts/dom.d.ts +2 -2
- package/dist/dts/interfaces.d.ts +7 -7
- package/dist/dts/observation/arrays.d.ts +1 -1
- package/dist/dts/observation/observable.d.ts +2 -2
- package/dist/dts/state/state.d.ts +9 -9
- package/dist/dts/styles/css-binding-directive.d.ts +1 -1
- package/dist/dts/styles/css-directive.d.ts +1 -1
- package/dist/dts/styles/css.d.ts +2 -2
- package/dist/dts/styles/element-styles.d.ts +2 -2
- package/dist/dts/templating/children.d.ts +1 -1
- package/dist/dts/templating/compiler.d.ts +1 -1
- package/dist/dts/templating/html-directive.d.ts +3 -3
- package/dist/dts/templating/node-observation.d.ts +1 -1
- package/dist/dts/templating/render.d.ts +6 -6
- package/dist/dts/templating/template.d.ts +2 -2
- package/dist/esm/components/element-controller.js +84 -84
- package/dist/esm/components/fast-definitions.js +15 -15
- package/dist/esm/di/di.js +12 -12
- package/dist/esm/hydration/target-builder.js +21 -7
- package/dist/esm/observation/arrays.js +12 -12
- package/dist/esm/styles/element-styles.js +9 -9
- package/dist/esm/templating/repeat.js +7 -7
- package/dist/esm/templating/view.js +9 -9
- package/dist/fast-element.api.json +26 -26
- package/dist/fast-element.d.ts +4 -4
- package/dist/fast-element.debug.js +162 -146
- package/dist/fast-element.debug.min.js +2 -2
- package/dist/fast-element.js +162 -146
- package/dist/fast-element.min.js +2 -2
- package/docs/di/api-report.api.md +4 -4
- package/karma.conf.cjs +13 -7
- package/package.json +3 -44
|
@@ -1761,18 +1761,6 @@ function setNonEnumerable(target, property, value, writable = true) {
|
|
|
1761
1761
|
});
|
|
1762
1762
|
}
|
|
1763
1763
|
class DefaultArrayObserver extends SubscriberSet {
|
|
1764
|
-
constructor(subject) {
|
|
1765
|
-
super(subject);
|
|
1766
|
-
this.oldCollection = void 0;
|
|
1767
|
-
this.splices = void 0;
|
|
1768
|
-
this.sorts = void 0;
|
|
1769
|
-
this.needsQueue = true;
|
|
1770
|
-
this._strategy = null;
|
|
1771
|
-
this._lengthObserver = void 0;
|
|
1772
|
-
this._sortObserver = void 0;
|
|
1773
|
-
this.call = this.flush;
|
|
1774
|
-
setNonEnumerable(subject, "$fastController", this);
|
|
1775
|
-
}
|
|
1776
1764
|
get strategy() {
|
|
1777
1765
|
return this._strategy;
|
|
1778
1766
|
}
|
|
@@ -1813,6 +1801,18 @@ class DefaultArrayObserver extends SubscriberSet {
|
|
|
1813
1801
|
}
|
|
1814
1802
|
return observer;
|
|
1815
1803
|
}
|
|
1804
|
+
constructor(subject) {
|
|
1805
|
+
super(subject);
|
|
1806
|
+
this.oldCollection = void 0;
|
|
1807
|
+
this.splices = void 0;
|
|
1808
|
+
this.sorts = void 0;
|
|
1809
|
+
this.needsQueue = true;
|
|
1810
|
+
this._strategy = null;
|
|
1811
|
+
this._lengthObserver = void 0;
|
|
1812
|
+
this._sortObserver = void 0;
|
|
1813
|
+
this.call = this.flush;
|
|
1814
|
+
setNonEnumerable(subject, "$fastController", this);
|
|
1815
|
+
}
|
|
1816
1816
|
subscribe(subscriber) {
|
|
1817
1817
|
this.flush();
|
|
1818
1818
|
super.subscribe(subscriber);
|
|
@@ -2036,6 +2036,15 @@ function reduceStyles(styles) {
|
|
|
2036
2036
|
* @public
|
|
2037
2037
|
*/
|
|
2038
2038
|
class ElementStyles {
|
|
2039
|
+
/**
|
|
2040
|
+
* Gets the StyleStrategy associated with these element styles.
|
|
2041
|
+
*/
|
|
2042
|
+
get strategy() {
|
|
2043
|
+
if (this._strategy === null) {
|
|
2044
|
+
this.withStrategy(DefaultStyleStrategy);
|
|
2045
|
+
}
|
|
2046
|
+
return this._strategy;
|
|
2047
|
+
}
|
|
2039
2048
|
/**
|
|
2040
2049
|
* Creates an instance of ElementStyles.
|
|
2041
2050
|
* @param styles - The styles that will be associated with elements.
|
|
@@ -2048,15 +2057,6 @@ class ElementStyles {
|
|
|
2048
2057
|
.map((x) => x instanceof ElementStyles ? x.behaviors : null)
|
|
2049
2058
|
.reduce((prev, curr) => (curr === null ? prev : prev === null ? curr : prev.concat(curr)), null);
|
|
2050
2059
|
}
|
|
2051
|
-
/**
|
|
2052
|
-
* Gets the StyleStrategy associated with these element styles.
|
|
2053
|
-
*/
|
|
2054
|
-
get strategy() {
|
|
2055
|
-
if (this._strategy === null) {
|
|
2056
|
-
this.withStrategy(DefaultStyleStrategy);
|
|
2057
|
-
}
|
|
2058
|
-
return this._strategy;
|
|
2059
|
-
}
|
|
2060
2060
|
/** @internal */
|
|
2061
2061
|
addStylesTo(target) {
|
|
2062
2062
|
this.strategy.addStylesTo(target);
|
|
@@ -2728,6 +2728,7 @@ function isShadowRoot(node) {
|
|
|
2728
2728
|
function buildViewBindingTargets(firstNode, lastNode, factories) {
|
|
2729
2729
|
const range = createRangeForNodes(firstNode, lastNode);
|
|
2730
2730
|
const treeRoot = range.commonAncestorContainer;
|
|
2731
|
+
const hydrationIndexOffset = getHydrationIndexOffset(factories);
|
|
2731
2732
|
const walker = document.createTreeWalker(treeRoot, NodeFilter.SHOW_ELEMENT + NodeFilter.SHOW_COMMENT + NodeFilter.SHOW_TEXT, {
|
|
2732
2733
|
acceptNode(node) {
|
|
2733
2734
|
return range.comparePoint(node, 0) === 0
|
|
@@ -2741,11 +2742,11 @@ function buildViewBindingTargets(firstNode, lastNode, factories) {
|
|
|
2741
2742
|
while (node !== null) {
|
|
2742
2743
|
switch (node.nodeType) {
|
|
2743
2744
|
case Node.ELEMENT_NODE: {
|
|
2744
|
-
targetElement(node, factories, targets);
|
|
2745
|
+
targetElement(node, factories, targets, hydrationIndexOffset);
|
|
2745
2746
|
break;
|
|
2746
2747
|
}
|
|
2747
2748
|
case Node.COMMENT_NODE: {
|
|
2748
|
-
targetComment(node, walker, factories, targets, boundaries);
|
|
2749
|
+
targetComment(node, walker, factories, targets, boundaries, hydrationIndexOffset);
|
|
2749
2750
|
break;
|
|
2750
2751
|
}
|
|
2751
2752
|
}
|
|
@@ -2754,21 +2755,22 @@ function buildViewBindingTargets(firstNode, lastNode, factories) {
|
|
|
2754
2755
|
range.detach();
|
|
2755
2756
|
return { targets, boundaries };
|
|
2756
2757
|
}
|
|
2757
|
-
function targetElement(node, factories, targets) {
|
|
2758
|
+
function targetElement(node, factories, targets, hydrationIndexOffset) {
|
|
2758
2759
|
var _a, _b;
|
|
2759
2760
|
// Check for attributes and map any factories.
|
|
2760
2761
|
const attrFactoryIds = (_b = (_a = HydrationMarkup.parseAttributeBinding(node)) !== null && _a !== void 0 ? _a : HydrationMarkup.parseEnumeratedAttributeBinding(node)) !== null && _b !== void 0 ? _b : HydrationMarkup.parseCompactAttributeBinding(node);
|
|
2761
2762
|
if (attrFactoryIds !== null) {
|
|
2762
2763
|
for (const id of attrFactoryIds) {
|
|
2763
|
-
|
|
2764
|
+
const factory = factories[id + hydrationIndexOffset];
|
|
2765
|
+
if (!factory) {
|
|
2764
2766
|
throw new HydrationTargetElementError(`HydrationView was unable to successfully target factory on ${node.nodeName} inside ${node.getRootNode().host.nodeName}. This likely indicates a template mismatch between SSR rendering and hydration.`, factories, node);
|
|
2765
2767
|
}
|
|
2766
|
-
targetFactory(
|
|
2768
|
+
targetFactory(factory, node, targets);
|
|
2767
2769
|
}
|
|
2768
2770
|
node.removeAttribute(HydrationMarkup.attributeMarkerName);
|
|
2769
2771
|
}
|
|
2770
2772
|
}
|
|
2771
|
-
function targetComment(node, walker, factories, targets, boundaries) {
|
|
2773
|
+
function targetComment(node, walker, factories, targets, boundaries, hydrationIndexOffset) {
|
|
2772
2774
|
if (HydrationMarkup.isElementBoundaryStartMarker(node)) {
|
|
2773
2775
|
skipToElementBoundaryEndMarker(node, walker);
|
|
2774
2776
|
return;
|
|
@@ -2779,7 +2781,7 @@ function targetComment(node, walker, factories, targets, boundaries) {
|
|
|
2779
2781
|
return;
|
|
2780
2782
|
}
|
|
2781
2783
|
const [index, id] = parsed;
|
|
2782
|
-
const factory = factories[index];
|
|
2784
|
+
const factory = factories[index + hydrationIndexOffset];
|
|
2783
2785
|
const nodes = [];
|
|
2784
2786
|
let current = walker.nextSibling();
|
|
2785
2787
|
node.data = "";
|
|
@@ -2843,6 +2845,18 @@ function skipToElementBoundaryEndMarker(node, walker) {
|
|
|
2843
2845
|
current = walker.nextSibling();
|
|
2844
2846
|
}
|
|
2845
2847
|
}
|
|
2848
|
+
function getHydrationIndexOffset(factories) {
|
|
2849
|
+
let offset = 0;
|
|
2850
|
+
for (let i = 0, ii = factories.length; i < ii; ++i) {
|
|
2851
|
+
if (factories[i].targetNodeId === "h") {
|
|
2852
|
+
offset++;
|
|
2853
|
+
}
|
|
2854
|
+
else {
|
|
2855
|
+
break;
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
return offset;
|
|
2859
|
+
}
|
|
2846
2860
|
function targetFactory(factory, node, targets) {
|
|
2847
2861
|
if (factory.targetNodeId === undefined) {
|
|
2848
2862
|
// Dev error, this shouldn't ever be thrown
|
|
@@ -2851,7 +2865,7 @@ function targetFactory(factory, node, targets) {
|
|
|
2851
2865
|
targets[factory.targetNodeId] = node;
|
|
2852
2866
|
}
|
|
2853
2867
|
|
|
2854
|
-
var _a;
|
|
2868
|
+
var _a$1;
|
|
2855
2869
|
function removeNodeSequence(firstNode, lastNode) {
|
|
2856
2870
|
const parent = firstNode.parentNode;
|
|
2857
2871
|
let current = firstNode;
|
|
@@ -3127,13 +3141,22 @@ class HydrationBindingError extends Error {
|
|
|
3127
3141
|
}
|
|
3128
3142
|
}
|
|
3129
3143
|
class HydrationView extends DefaultExecutionContext {
|
|
3144
|
+
get hydrationStage() {
|
|
3145
|
+
return this._hydrationStage;
|
|
3146
|
+
}
|
|
3147
|
+
get targets() {
|
|
3148
|
+
return this._targets;
|
|
3149
|
+
}
|
|
3150
|
+
get bindingViewBoundaries() {
|
|
3151
|
+
return this._bindingViewBoundaries;
|
|
3152
|
+
}
|
|
3130
3153
|
constructor(firstChild, lastChild, sourceTemplate, hostBindingTarget) {
|
|
3131
3154
|
super();
|
|
3132
3155
|
this.firstChild = firstChild;
|
|
3133
3156
|
this.lastChild = lastChild;
|
|
3134
3157
|
this.sourceTemplate = sourceTemplate;
|
|
3135
3158
|
this.hostBindingTarget = hostBindingTarget;
|
|
3136
|
-
this[_a] = Hydratable;
|
|
3159
|
+
this[_a$1] = Hydratable;
|
|
3137
3160
|
this.context = this;
|
|
3138
3161
|
this.source = null;
|
|
3139
3162
|
this.isBound = false;
|
|
@@ -3146,15 +3169,6 @@ class HydrationView extends DefaultExecutionContext {
|
|
|
3146
3169
|
this._targets = {};
|
|
3147
3170
|
this.factories = sourceTemplate.compile().factories;
|
|
3148
3171
|
}
|
|
3149
|
-
get hydrationStage() {
|
|
3150
|
-
return this._hydrationStage;
|
|
3151
|
-
}
|
|
3152
|
-
get targets() {
|
|
3153
|
-
return this._targets;
|
|
3154
|
-
}
|
|
3155
|
-
get bindingViewBoundaries() {
|
|
3156
|
-
return this._bindingViewBoundaries;
|
|
3157
|
-
}
|
|
3158
3172
|
/**
|
|
3159
3173
|
* no-op. Hydrated views are don't need to be moved from a documentFragment
|
|
3160
3174
|
* to the target node.
|
|
@@ -3320,7 +3334,7 @@ class HydrationView extends DefaultExecutionContext {
|
|
|
3320
3334
|
unbindables.length = 0;
|
|
3321
3335
|
}
|
|
3322
3336
|
}
|
|
3323
|
-
_a = Hydratable;
|
|
3337
|
+
_a$1 = Hydratable;
|
|
3324
3338
|
makeSerializationNoop(HydrationView);
|
|
3325
3339
|
|
|
3326
3340
|
function isContentTemplate(value) {
|
|
@@ -4372,6 +4386,13 @@ class RepeatBehavior {
|
|
|
4372
4386
|
* @public
|
|
4373
4387
|
*/
|
|
4374
4388
|
class RepeatDirective {
|
|
4389
|
+
/**
|
|
4390
|
+
* Creates a placeholder string based on the directive's index within the template.
|
|
4391
|
+
* @param index - The index of the directive within the template.
|
|
4392
|
+
*/
|
|
4393
|
+
createHTML(add) {
|
|
4394
|
+
return Markup.comment(add(this));
|
|
4395
|
+
}
|
|
4375
4396
|
/**
|
|
4376
4397
|
* Creates an instance of RepeatDirective.
|
|
4377
4398
|
* @param dataBinding - The binding that provides the array to render.
|
|
@@ -4384,13 +4405,6 @@ class RepeatDirective {
|
|
|
4384
4405
|
this.options = options;
|
|
4385
4406
|
ArrayObserver.enable();
|
|
4386
4407
|
}
|
|
4387
|
-
/**
|
|
4388
|
-
* Creates a placeholder string based on the directive's index within the template.
|
|
4389
|
-
* @param index - The index of the directive within the template.
|
|
4390
|
-
*/
|
|
4391
|
-
createHTML(add) {
|
|
4392
|
-
return Markup.comment(add(this));
|
|
4393
|
-
}
|
|
4394
4408
|
/**
|
|
4395
4409
|
* Creates a behavior for the provided target node.
|
|
4396
4410
|
* @param target - The node instance to create the behavior for.
|
|
@@ -4850,6 +4864,7 @@ function attr(configOrTarget, prop) {
|
|
|
4850
4864
|
return decorator;
|
|
4851
4865
|
}
|
|
4852
4866
|
|
|
4867
|
+
var _a;
|
|
4853
4868
|
const defaultShadowOptions = { mode: "open" };
|
|
4854
4869
|
const defaultElementOptions = {};
|
|
4855
4870
|
const fastElementBaseTypes = new Set();
|
|
@@ -4870,6 +4885,12 @@ const TemplateOptions = {
|
|
|
4870
4885
|
* @public
|
|
4871
4886
|
*/
|
|
4872
4887
|
class FASTElementDefinition {
|
|
4888
|
+
/**
|
|
4889
|
+
* Indicates if this element has been defined in at least one registry.
|
|
4890
|
+
*/
|
|
4891
|
+
get isDefined() {
|
|
4892
|
+
return this.platformDefined;
|
|
4893
|
+
}
|
|
4873
4894
|
constructor(type, nameOrConfig = type.definition) {
|
|
4874
4895
|
var _b;
|
|
4875
4896
|
this.platformDefined = false;
|
|
@@ -4912,14 +4933,8 @@ class FASTElementDefinition {
|
|
|
4912
4933
|
: Object.assign(Object.assign({}, defaultElementOptions), nameOrConfig.elementOptions);
|
|
4913
4934
|
this.styles = ElementStyles.normalize(nameOrConfig.styles);
|
|
4914
4935
|
fastElementRegistry.register(this);
|
|
4915
|
-
Observable.defineProperty(
|
|
4916
|
-
|
|
4917
|
-
}
|
|
4918
|
-
/**
|
|
4919
|
-
* Indicates if this element has been defined in at least one registry.
|
|
4920
|
-
*/
|
|
4921
|
-
get isDefined() {
|
|
4922
|
-
return this.platformDefined;
|
|
4936
|
+
Observable.defineProperty(_a.isRegistered, this.name);
|
|
4937
|
+
_a.isRegistered[this.name] = this.type;
|
|
4923
4938
|
}
|
|
4924
4939
|
/**
|
|
4925
4940
|
* Defines a custom element based on this definition.
|
|
@@ -4945,10 +4960,10 @@ class FASTElementDefinition {
|
|
|
4945
4960
|
*/
|
|
4946
4961
|
static compose(type, nameOrDef) {
|
|
4947
4962
|
if (fastElementBaseTypes.has(type) || fastElementRegistry.getByType(type)) {
|
|
4948
|
-
return new
|
|
4963
|
+
return new _a(class extends type {
|
|
4949
4964
|
}, nameOrDef);
|
|
4950
4965
|
}
|
|
4951
|
-
return new
|
|
4966
|
+
return new _a(type, nameOrDef);
|
|
4952
4967
|
}
|
|
4953
4968
|
/**
|
|
4954
4969
|
* Registers a FASTElement base type.
|
|
@@ -4970,10 +4985,10 @@ class FASTElementDefinition {
|
|
|
4970
4985
|
static composeAsync(type, nameOrDef) {
|
|
4971
4986
|
return new Promise(resolve => {
|
|
4972
4987
|
if (fastElementBaseTypes.has(type) || fastElementRegistry.getByType(type)) {
|
|
4973
|
-
resolve(new
|
|
4988
|
+
resolve(new _a(class extends type {
|
|
4974
4989
|
}, nameOrDef));
|
|
4975
4990
|
}
|
|
4976
|
-
const definition = new
|
|
4991
|
+
const definition = new _a(type, nameOrDef);
|
|
4977
4992
|
Observable.getNotifier(definition).subscribe({
|
|
4978
4993
|
handleChange: () => {
|
|
4979
4994
|
var _b, _c;
|
|
@@ -4984,6 +4999,7 @@ class FASTElementDefinition {
|
|
|
4984
4999
|
});
|
|
4985
5000
|
}
|
|
4986
5001
|
}
|
|
5002
|
+
_a = FASTElementDefinition;
|
|
4987
5003
|
/**
|
|
4988
5004
|
* The definition has been registered to the FAST element registry.
|
|
4989
5005
|
*/
|
|
@@ -5005,10 +5021,10 @@ FASTElementDefinition.getForInstance = fastElementRegistry.getForInstance;
|
|
|
5005
5021
|
*/
|
|
5006
5022
|
FASTElementDefinition.registerAsync = (name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5007
5023
|
return new Promise(resolve => {
|
|
5008
|
-
if (
|
|
5009
|
-
resolve(
|
|
5024
|
+
if (_a.isRegistered[name]) {
|
|
5025
|
+
resolve(_a.isRegistered[name]);
|
|
5010
5026
|
}
|
|
5011
|
-
Observable.getNotifier(
|
|
5027
|
+
Observable.getNotifier(_a.isRegistered).subscribe({ handleChange: () => resolve(_a.isRegistered[name]) }, name);
|
|
5012
5028
|
});
|
|
5013
5029
|
});
|
|
5014
5030
|
Observable.defineProperty(FASTElementDefinition.prototype, "template");
|
|
@@ -5536,90 +5552,6 @@ let elementControllerStrategy;
|
|
|
5536
5552
|
* @public
|
|
5537
5553
|
*/
|
|
5538
5554
|
class ElementController extends PropertyChangeNotifier {
|
|
5539
|
-
/**
|
|
5540
|
-
* Creates a Controller to control the specified element.
|
|
5541
|
-
* @param element - The element to be controlled by this controller.
|
|
5542
|
-
* @param definition - The element definition metadata that instructs this
|
|
5543
|
-
* controller in how to handle rendering and other platform integrations.
|
|
5544
|
-
* @internal
|
|
5545
|
-
*/
|
|
5546
|
-
constructor(element, definition) {
|
|
5547
|
-
super(element);
|
|
5548
|
-
/**
|
|
5549
|
-
* A map of observable properties that were set on the element before upgrade.
|
|
5550
|
-
*/
|
|
5551
|
-
this.boundObservables = null;
|
|
5552
|
-
/**
|
|
5553
|
-
* Indicates whether the controller needs to perform initial rendering.
|
|
5554
|
-
*/
|
|
5555
|
-
this.needsInitialization = true;
|
|
5556
|
-
/**
|
|
5557
|
-
* Indicates whether the element has an existing shadow root (e.g. from declarative shadow DOM).
|
|
5558
|
-
*/
|
|
5559
|
-
this.hasExistingShadowRoot = false;
|
|
5560
|
-
/**
|
|
5561
|
-
* The template used to render the component.
|
|
5562
|
-
*/
|
|
5563
|
-
this._template = null;
|
|
5564
|
-
/**
|
|
5565
|
-
* The current lifecycle stage of the controller.
|
|
5566
|
-
*/
|
|
5567
|
-
this.stage = 3 /* Stages.disconnected */;
|
|
5568
|
-
/**
|
|
5569
|
-
* A guard against connecting behaviors multiple times
|
|
5570
|
-
* during connect in scenarios where a behavior adds
|
|
5571
|
-
* another behavior during it's connectedCallback
|
|
5572
|
-
*/
|
|
5573
|
-
this.guardBehaviorConnection = false;
|
|
5574
|
-
/**
|
|
5575
|
-
* The behaviors associated with the component.
|
|
5576
|
-
*/
|
|
5577
|
-
this.behaviors = null;
|
|
5578
|
-
/**
|
|
5579
|
-
* Tracks whether behaviors are connected so that
|
|
5580
|
-
* behaviors cant be connected multiple times
|
|
5581
|
-
*/
|
|
5582
|
-
this.behaviorsConnected = false;
|
|
5583
|
-
/**
|
|
5584
|
-
* The main set of styles used for the component, independent of any
|
|
5585
|
-
* dynamically added styles.
|
|
5586
|
-
*/
|
|
5587
|
-
this._mainStyles = null;
|
|
5588
|
-
/**
|
|
5589
|
-
* This allows Observable.getNotifier(...) to return the Controller
|
|
5590
|
-
* when the notifier for the Controller itself is being requested. The
|
|
5591
|
-
* result is that the Observable system does not need to create a separate
|
|
5592
|
-
* instance of Notifier for observables on the Controller. The component and
|
|
5593
|
-
* the controller will now share the same notifier, removing one-object construct
|
|
5594
|
-
* per web component instance.
|
|
5595
|
-
*/
|
|
5596
|
-
this.$fastController = this;
|
|
5597
|
-
/**
|
|
5598
|
-
* The view associated with the custom element.
|
|
5599
|
-
* @remarks
|
|
5600
|
-
* If `null` then the element is managing its own rendering.
|
|
5601
|
-
*/
|
|
5602
|
-
this.view = null;
|
|
5603
|
-
this.source = element;
|
|
5604
|
-
this.definition = definition;
|
|
5605
|
-
this.shadowOptions = definition.shadowOptions;
|
|
5606
|
-
// Capture any observable values that were set by the binding engine before
|
|
5607
|
-
// the browser upgraded the element. Then delete the property since it will
|
|
5608
|
-
// shadow the getter/setter that is required to make the observable operate.
|
|
5609
|
-
// Later, in the connect callback, we'll re-apply the values.
|
|
5610
|
-
const accessors = Observable.getAccessors(element);
|
|
5611
|
-
if (accessors.length > 0) {
|
|
5612
|
-
const boundObservables = (this.boundObservables = Object.create(null));
|
|
5613
|
-
for (let i = 0, ii = accessors.length; i < ii; ++i) {
|
|
5614
|
-
const propertyName = accessors[i].name;
|
|
5615
|
-
const value = element[propertyName];
|
|
5616
|
-
if (value !== void 0) {
|
|
5617
|
-
delete element[propertyName];
|
|
5618
|
-
boundObservables[propertyName] = value;
|
|
5619
|
-
}
|
|
5620
|
-
}
|
|
5621
|
-
}
|
|
5622
|
-
}
|
|
5623
5555
|
/**
|
|
5624
5556
|
* Indicates whether or not the custom element has been
|
|
5625
5557
|
* connected to the document.
|
|
@@ -5733,6 +5665,90 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
5733
5665
|
this.addStyles(value);
|
|
5734
5666
|
}
|
|
5735
5667
|
}
|
|
5668
|
+
/**
|
|
5669
|
+
* Creates a Controller to control the specified element.
|
|
5670
|
+
* @param element - The element to be controlled by this controller.
|
|
5671
|
+
* @param definition - The element definition metadata that instructs this
|
|
5672
|
+
* controller in how to handle rendering and other platform integrations.
|
|
5673
|
+
* @internal
|
|
5674
|
+
*/
|
|
5675
|
+
constructor(element, definition) {
|
|
5676
|
+
super(element);
|
|
5677
|
+
/**
|
|
5678
|
+
* A map of observable properties that were set on the element before upgrade.
|
|
5679
|
+
*/
|
|
5680
|
+
this.boundObservables = null;
|
|
5681
|
+
/**
|
|
5682
|
+
* Indicates whether the controller needs to perform initial rendering.
|
|
5683
|
+
*/
|
|
5684
|
+
this.needsInitialization = true;
|
|
5685
|
+
/**
|
|
5686
|
+
* Indicates whether the element has an existing shadow root (e.g. from declarative shadow DOM).
|
|
5687
|
+
*/
|
|
5688
|
+
this.hasExistingShadowRoot = false;
|
|
5689
|
+
/**
|
|
5690
|
+
* The template used to render the component.
|
|
5691
|
+
*/
|
|
5692
|
+
this._template = null;
|
|
5693
|
+
/**
|
|
5694
|
+
* The current lifecycle stage of the controller.
|
|
5695
|
+
*/
|
|
5696
|
+
this.stage = 3 /* Stages.disconnected */;
|
|
5697
|
+
/**
|
|
5698
|
+
* A guard against connecting behaviors multiple times
|
|
5699
|
+
* during connect in scenarios where a behavior adds
|
|
5700
|
+
* another behavior during it's connectedCallback
|
|
5701
|
+
*/
|
|
5702
|
+
this.guardBehaviorConnection = false;
|
|
5703
|
+
/**
|
|
5704
|
+
* The behaviors associated with the component.
|
|
5705
|
+
*/
|
|
5706
|
+
this.behaviors = null;
|
|
5707
|
+
/**
|
|
5708
|
+
* Tracks whether behaviors are connected so that
|
|
5709
|
+
* behaviors cant be connected multiple times
|
|
5710
|
+
*/
|
|
5711
|
+
this.behaviorsConnected = false;
|
|
5712
|
+
/**
|
|
5713
|
+
* The main set of styles used for the component, independent of any
|
|
5714
|
+
* dynamically added styles.
|
|
5715
|
+
*/
|
|
5716
|
+
this._mainStyles = null;
|
|
5717
|
+
/**
|
|
5718
|
+
* This allows Observable.getNotifier(...) to return the Controller
|
|
5719
|
+
* when the notifier for the Controller itself is being requested. The
|
|
5720
|
+
* result is that the Observable system does not need to create a separate
|
|
5721
|
+
* instance of Notifier for observables on the Controller. The component and
|
|
5722
|
+
* the controller will now share the same notifier, removing one-object construct
|
|
5723
|
+
* per web component instance.
|
|
5724
|
+
*/
|
|
5725
|
+
this.$fastController = this;
|
|
5726
|
+
/**
|
|
5727
|
+
* The view associated with the custom element.
|
|
5728
|
+
* @remarks
|
|
5729
|
+
* If `null` then the element is managing its own rendering.
|
|
5730
|
+
*/
|
|
5731
|
+
this.view = null;
|
|
5732
|
+
this.source = element;
|
|
5733
|
+
this.definition = definition;
|
|
5734
|
+
this.shadowOptions = definition.shadowOptions;
|
|
5735
|
+
// Capture any observable values that were set by the binding engine before
|
|
5736
|
+
// the browser upgraded the element. Then delete the property since it will
|
|
5737
|
+
// shadow the getter/setter that is required to make the observable operate.
|
|
5738
|
+
// Later, in the connect callback, we'll re-apply the values.
|
|
5739
|
+
const accessors = Observable.getAccessors(element);
|
|
5740
|
+
if (accessors.length > 0) {
|
|
5741
|
+
const boundObservables = (this.boundObservables = Object.create(null));
|
|
5742
|
+
for (let i = 0, ii = accessors.length; i < ii; ++i) {
|
|
5743
|
+
const propertyName = accessors[i].name;
|
|
5744
|
+
const value = element[propertyName];
|
|
5745
|
+
if (value !== void 0) {
|
|
5746
|
+
delete element[propertyName];
|
|
5747
|
+
boundObservables[propertyName] = value;
|
|
5748
|
+
}
|
|
5749
|
+
}
|
|
5750
|
+
}
|
|
5751
|
+
}
|
|
5736
5752
|
/**
|
|
5737
5753
|
* Registers an unbind handler with the controller.
|
|
5738
5754
|
* @param behavior - An object to call when the controller unbinds.
|