@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
package/dist/fast-element.js
CHANGED
|
@@ -1691,18 +1691,6 @@ function setNonEnumerable(target, property, value, writable = true) {
|
|
|
1691
1691
|
});
|
|
1692
1692
|
}
|
|
1693
1693
|
class DefaultArrayObserver extends SubscriberSet {
|
|
1694
|
-
constructor(subject) {
|
|
1695
|
-
super(subject);
|
|
1696
|
-
this.oldCollection = void 0;
|
|
1697
|
-
this.splices = void 0;
|
|
1698
|
-
this.sorts = void 0;
|
|
1699
|
-
this.needsQueue = true;
|
|
1700
|
-
this._strategy = null;
|
|
1701
|
-
this._lengthObserver = void 0;
|
|
1702
|
-
this._sortObserver = void 0;
|
|
1703
|
-
this.call = this.flush;
|
|
1704
|
-
setNonEnumerable(subject, "$fastController", this);
|
|
1705
|
-
}
|
|
1706
1694
|
get strategy() {
|
|
1707
1695
|
return this._strategy;
|
|
1708
1696
|
}
|
|
@@ -1743,6 +1731,18 @@ class DefaultArrayObserver extends SubscriberSet {
|
|
|
1743
1731
|
}
|
|
1744
1732
|
return observer;
|
|
1745
1733
|
}
|
|
1734
|
+
constructor(subject) {
|
|
1735
|
+
super(subject);
|
|
1736
|
+
this.oldCollection = void 0;
|
|
1737
|
+
this.splices = void 0;
|
|
1738
|
+
this.sorts = void 0;
|
|
1739
|
+
this.needsQueue = true;
|
|
1740
|
+
this._strategy = null;
|
|
1741
|
+
this._lengthObserver = void 0;
|
|
1742
|
+
this._sortObserver = void 0;
|
|
1743
|
+
this.call = this.flush;
|
|
1744
|
+
setNonEnumerable(subject, "$fastController", this);
|
|
1745
|
+
}
|
|
1746
1746
|
subscribe(subscriber) {
|
|
1747
1747
|
this.flush();
|
|
1748
1748
|
super.subscribe(subscriber);
|
|
@@ -1966,6 +1966,15 @@ function reduceStyles(styles) {
|
|
|
1966
1966
|
* @public
|
|
1967
1967
|
*/
|
|
1968
1968
|
class ElementStyles {
|
|
1969
|
+
/**
|
|
1970
|
+
* Gets the StyleStrategy associated with these element styles.
|
|
1971
|
+
*/
|
|
1972
|
+
get strategy() {
|
|
1973
|
+
if (this._strategy === null) {
|
|
1974
|
+
this.withStrategy(DefaultStyleStrategy);
|
|
1975
|
+
}
|
|
1976
|
+
return this._strategy;
|
|
1977
|
+
}
|
|
1969
1978
|
/**
|
|
1970
1979
|
* Creates an instance of ElementStyles.
|
|
1971
1980
|
* @param styles - The styles that will be associated with elements.
|
|
@@ -1978,15 +1987,6 @@ class ElementStyles {
|
|
|
1978
1987
|
.map((x) => x instanceof ElementStyles ? x.behaviors : null)
|
|
1979
1988
|
.reduce((prev, curr) => (curr === null ? prev : prev === null ? curr : prev.concat(curr)), null);
|
|
1980
1989
|
}
|
|
1981
|
-
/**
|
|
1982
|
-
* Gets the StyleStrategy associated with these element styles.
|
|
1983
|
-
*/
|
|
1984
|
-
get strategy() {
|
|
1985
|
-
if (this._strategy === null) {
|
|
1986
|
-
this.withStrategy(DefaultStyleStrategy);
|
|
1987
|
-
}
|
|
1988
|
-
return this._strategy;
|
|
1989
|
-
}
|
|
1990
1990
|
/** @internal */
|
|
1991
1991
|
addStylesTo(target) {
|
|
1992
1992
|
this.strategy.addStylesTo(target);
|
|
@@ -2658,6 +2658,7 @@ function isShadowRoot(node) {
|
|
|
2658
2658
|
function buildViewBindingTargets(firstNode, lastNode, factories) {
|
|
2659
2659
|
const range = createRangeForNodes(firstNode, lastNode);
|
|
2660
2660
|
const treeRoot = range.commonAncestorContainer;
|
|
2661
|
+
const hydrationIndexOffset = getHydrationIndexOffset(factories);
|
|
2661
2662
|
const walker = document.createTreeWalker(treeRoot, NodeFilter.SHOW_ELEMENT + NodeFilter.SHOW_COMMENT + NodeFilter.SHOW_TEXT, {
|
|
2662
2663
|
acceptNode(node) {
|
|
2663
2664
|
return range.comparePoint(node, 0) === 0
|
|
@@ -2671,11 +2672,11 @@ function buildViewBindingTargets(firstNode, lastNode, factories) {
|
|
|
2671
2672
|
while (node !== null) {
|
|
2672
2673
|
switch (node.nodeType) {
|
|
2673
2674
|
case Node.ELEMENT_NODE: {
|
|
2674
|
-
targetElement(node, factories, targets);
|
|
2675
|
+
targetElement(node, factories, targets, hydrationIndexOffset);
|
|
2675
2676
|
break;
|
|
2676
2677
|
}
|
|
2677
2678
|
case Node.COMMENT_NODE: {
|
|
2678
|
-
targetComment(node, walker, factories, targets, boundaries);
|
|
2679
|
+
targetComment(node, walker, factories, targets, boundaries, hydrationIndexOffset);
|
|
2679
2680
|
break;
|
|
2680
2681
|
}
|
|
2681
2682
|
}
|
|
@@ -2684,21 +2685,22 @@ function buildViewBindingTargets(firstNode, lastNode, factories) {
|
|
|
2684
2685
|
range.detach();
|
|
2685
2686
|
return { targets, boundaries };
|
|
2686
2687
|
}
|
|
2687
|
-
function targetElement(node, factories, targets) {
|
|
2688
|
+
function targetElement(node, factories, targets, hydrationIndexOffset) {
|
|
2688
2689
|
var _a, _b;
|
|
2689
2690
|
// Check for attributes and map any factories.
|
|
2690
2691
|
const attrFactoryIds = (_b = (_a = HydrationMarkup.parseAttributeBinding(node)) !== null && _a !== void 0 ? _a : HydrationMarkup.parseEnumeratedAttributeBinding(node)) !== null && _b !== void 0 ? _b : HydrationMarkup.parseCompactAttributeBinding(node);
|
|
2691
2692
|
if (attrFactoryIds !== null) {
|
|
2692
2693
|
for (const id of attrFactoryIds) {
|
|
2693
|
-
|
|
2694
|
+
const factory = factories[id + hydrationIndexOffset];
|
|
2695
|
+
if (!factory) {
|
|
2694
2696
|
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);
|
|
2695
2697
|
}
|
|
2696
|
-
targetFactory(
|
|
2698
|
+
targetFactory(factory, node, targets);
|
|
2697
2699
|
}
|
|
2698
2700
|
node.removeAttribute(HydrationMarkup.attributeMarkerName);
|
|
2699
2701
|
}
|
|
2700
2702
|
}
|
|
2701
|
-
function targetComment(node, walker, factories, targets, boundaries) {
|
|
2703
|
+
function targetComment(node, walker, factories, targets, boundaries, hydrationIndexOffset) {
|
|
2702
2704
|
if (HydrationMarkup.isElementBoundaryStartMarker(node)) {
|
|
2703
2705
|
skipToElementBoundaryEndMarker(node, walker);
|
|
2704
2706
|
return;
|
|
@@ -2709,7 +2711,7 @@ function targetComment(node, walker, factories, targets, boundaries) {
|
|
|
2709
2711
|
return;
|
|
2710
2712
|
}
|
|
2711
2713
|
const [index, id] = parsed;
|
|
2712
|
-
const factory = factories[index];
|
|
2714
|
+
const factory = factories[index + hydrationIndexOffset];
|
|
2713
2715
|
const nodes = [];
|
|
2714
2716
|
let current = walker.nextSibling();
|
|
2715
2717
|
node.data = "";
|
|
@@ -2773,6 +2775,18 @@ function skipToElementBoundaryEndMarker(node, walker) {
|
|
|
2773
2775
|
current = walker.nextSibling();
|
|
2774
2776
|
}
|
|
2775
2777
|
}
|
|
2778
|
+
function getHydrationIndexOffset(factories) {
|
|
2779
|
+
let offset = 0;
|
|
2780
|
+
for (let i = 0, ii = factories.length; i < ii; ++i) {
|
|
2781
|
+
if (factories[i].targetNodeId === "h") {
|
|
2782
|
+
offset++;
|
|
2783
|
+
}
|
|
2784
|
+
else {
|
|
2785
|
+
break;
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
return offset;
|
|
2789
|
+
}
|
|
2776
2790
|
function targetFactory(factory, node, targets) {
|
|
2777
2791
|
if (factory.targetNodeId === undefined) {
|
|
2778
2792
|
// Dev error, this shouldn't ever be thrown
|
|
@@ -2781,7 +2795,7 @@ function targetFactory(factory, node, targets) {
|
|
|
2781
2795
|
targets[factory.targetNodeId] = node;
|
|
2782
2796
|
}
|
|
2783
2797
|
|
|
2784
|
-
var _a;
|
|
2798
|
+
var _a$1;
|
|
2785
2799
|
function removeNodeSequence(firstNode, lastNode) {
|
|
2786
2800
|
const parent = firstNode.parentNode;
|
|
2787
2801
|
let current = firstNode;
|
|
@@ -3057,13 +3071,22 @@ class HydrationBindingError extends Error {
|
|
|
3057
3071
|
}
|
|
3058
3072
|
}
|
|
3059
3073
|
class HydrationView extends DefaultExecutionContext {
|
|
3074
|
+
get hydrationStage() {
|
|
3075
|
+
return this._hydrationStage;
|
|
3076
|
+
}
|
|
3077
|
+
get targets() {
|
|
3078
|
+
return this._targets;
|
|
3079
|
+
}
|
|
3080
|
+
get bindingViewBoundaries() {
|
|
3081
|
+
return this._bindingViewBoundaries;
|
|
3082
|
+
}
|
|
3060
3083
|
constructor(firstChild, lastChild, sourceTemplate, hostBindingTarget) {
|
|
3061
3084
|
super();
|
|
3062
3085
|
this.firstChild = firstChild;
|
|
3063
3086
|
this.lastChild = lastChild;
|
|
3064
3087
|
this.sourceTemplate = sourceTemplate;
|
|
3065
3088
|
this.hostBindingTarget = hostBindingTarget;
|
|
3066
|
-
this[_a] = Hydratable;
|
|
3089
|
+
this[_a$1] = Hydratable;
|
|
3067
3090
|
this.context = this;
|
|
3068
3091
|
this.source = null;
|
|
3069
3092
|
this.isBound = false;
|
|
@@ -3076,15 +3099,6 @@ class HydrationView extends DefaultExecutionContext {
|
|
|
3076
3099
|
this._targets = {};
|
|
3077
3100
|
this.factories = sourceTemplate.compile().factories;
|
|
3078
3101
|
}
|
|
3079
|
-
get hydrationStage() {
|
|
3080
|
-
return this._hydrationStage;
|
|
3081
|
-
}
|
|
3082
|
-
get targets() {
|
|
3083
|
-
return this._targets;
|
|
3084
|
-
}
|
|
3085
|
-
get bindingViewBoundaries() {
|
|
3086
|
-
return this._bindingViewBoundaries;
|
|
3087
|
-
}
|
|
3088
3102
|
/**
|
|
3089
3103
|
* no-op. Hydrated views are don't need to be moved from a documentFragment
|
|
3090
3104
|
* to the target node.
|
|
@@ -3250,7 +3264,7 @@ class HydrationView extends DefaultExecutionContext {
|
|
|
3250
3264
|
unbindables.length = 0;
|
|
3251
3265
|
}
|
|
3252
3266
|
}
|
|
3253
|
-
_a = Hydratable;
|
|
3267
|
+
_a$1 = Hydratable;
|
|
3254
3268
|
makeSerializationNoop(HydrationView);
|
|
3255
3269
|
|
|
3256
3270
|
function isContentTemplate(value) {
|
|
@@ -4302,6 +4316,13 @@ class RepeatBehavior {
|
|
|
4302
4316
|
* @public
|
|
4303
4317
|
*/
|
|
4304
4318
|
class RepeatDirective {
|
|
4319
|
+
/**
|
|
4320
|
+
* Creates a placeholder string based on the directive's index within the template.
|
|
4321
|
+
* @param index - The index of the directive within the template.
|
|
4322
|
+
*/
|
|
4323
|
+
createHTML(add) {
|
|
4324
|
+
return Markup.comment(add(this));
|
|
4325
|
+
}
|
|
4305
4326
|
/**
|
|
4306
4327
|
* Creates an instance of RepeatDirective.
|
|
4307
4328
|
* @param dataBinding - The binding that provides the array to render.
|
|
@@ -4314,13 +4335,6 @@ class RepeatDirective {
|
|
|
4314
4335
|
this.options = options;
|
|
4315
4336
|
ArrayObserver.enable();
|
|
4316
4337
|
}
|
|
4317
|
-
/**
|
|
4318
|
-
* Creates a placeholder string based on the directive's index within the template.
|
|
4319
|
-
* @param index - The index of the directive within the template.
|
|
4320
|
-
*/
|
|
4321
|
-
createHTML(add) {
|
|
4322
|
-
return Markup.comment(add(this));
|
|
4323
|
-
}
|
|
4324
4338
|
/**
|
|
4325
4339
|
* Creates a behavior for the provided target node.
|
|
4326
4340
|
* @param target - The node instance to create the behavior for.
|
|
@@ -4780,6 +4794,7 @@ function attr(configOrTarget, prop) {
|
|
|
4780
4794
|
return decorator;
|
|
4781
4795
|
}
|
|
4782
4796
|
|
|
4797
|
+
var _a;
|
|
4783
4798
|
const defaultShadowOptions = { mode: "open" };
|
|
4784
4799
|
const defaultElementOptions = {};
|
|
4785
4800
|
const fastElementBaseTypes = new Set();
|
|
@@ -4800,6 +4815,12 @@ const TemplateOptions = {
|
|
|
4800
4815
|
* @public
|
|
4801
4816
|
*/
|
|
4802
4817
|
class FASTElementDefinition {
|
|
4818
|
+
/**
|
|
4819
|
+
* Indicates if this element has been defined in at least one registry.
|
|
4820
|
+
*/
|
|
4821
|
+
get isDefined() {
|
|
4822
|
+
return this.platformDefined;
|
|
4823
|
+
}
|
|
4803
4824
|
constructor(type, nameOrConfig = type.definition) {
|
|
4804
4825
|
var _b;
|
|
4805
4826
|
this.platformDefined = false;
|
|
@@ -4842,14 +4863,8 @@ class FASTElementDefinition {
|
|
|
4842
4863
|
: Object.assign(Object.assign({}, defaultElementOptions), nameOrConfig.elementOptions);
|
|
4843
4864
|
this.styles = ElementStyles.normalize(nameOrConfig.styles);
|
|
4844
4865
|
fastElementRegistry.register(this);
|
|
4845
|
-
Observable.defineProperty(
|
|
4846
|
-
|
|
4847
|
-
}
|
|
4848
|
-
/**
|
|
4849
|
-
* Indicates if this element has been defined in at least one registry.
|
|
4850
|
-
*/
|
|
4851
|
-
get isDefined() {
|
|
4852
|
-
return this.platformDefined;
|
|
4866
|
+
Observable.defineProperty(_a.isRegistered, this.name);
|
|
4867
|
+
_a.isRegistered[this.name] = this.type;
|
|
4853
4868
|
}
|
|
4854
4869
|
/**
|
|
4855
4870
|
* Defines a custom element based on this definition.
|
|
@@ -4875,10 +4890,10 @@ class FASTElementDefinition {
|
|
|
4875
4890
|
*/
|
|
4876
4891
|
static compose(type, nameOrDef) {
|
|
4877
4892
|
if (fastElementBaseTypes.has(type) || fastElementRegistry.getByType(type)) {
|
|
4878
|
-
return new
|
|
4893
|
+
return new _a(class extends type {
|
|
4879
4894
|
}, nameOrDef);
|
|
4880
4895
|
}
|
|
4881
|
-
return new
|
|
4896
|
+
return new _a(type, nameOrDef);
|
|
4882
4897
|
}
|
|
4883
4898
|
/**
|
|
4884
4899
|
* Registers a FASTElement base type.
|
|
@@ -4900,10 +4915,10 @@ class FASTElementDefinition {
|
|
|
4900
4915
|
static composeAsync(type, nameOrDef) {
|
|
4901
4916
|
return new Promise(resolve => {
|
|
4902
4917
|
if (fastElementBaseTypes.has(type) || fastElementRegistry.getByType(type)) {
|
|
4903
|
-
resolve(new
|
|
4918
|
+
resolve(new _a(class extends type {
|
|
4904
4919
|
}, nameOrDef));
|
|
4905
4920
|
}
|
|
4906
|
-
const definition = new
|
|
4921
|
+
const definition = new _a(type, nameOrDef);
|
|
4907
4922
|
Observable.getNotifier(definition).subscribe({
|
|
4908
4923
|
handleChange: () => {
|
|
4909
4924
|
var _b, _c;
|
|
@@ -4914,6 +4929,7 @@ class FASTElementDefinition {
|
|
|
4914
4929
|
});
|
|
4915
4930
|
}
|
|
4916
4931
|
}
|
|
4932
|
+
_a = FASTElementDefinition;
|
|
4917
4933
|
/**
|
|
4918
4934
|
* The definition has been registered to the FAST element registry.
|
|
4919
4935
|
*/
|
|
@@ -4935,10 +4951,10 @@ FASTElementDefinition.getForInstance = fastElementRegistry.getForInstance;
|
|
|
4935
4951
|
*/
|
|
4936
4952
|
FASTElementDefinition.registerAsync = (name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4937
4953
|
return new Promise(resolve => {
|
|
4938
|
-
if (
|
|
4939
|
-
resolve(
|
|
4954
|
+
if (_a.isRegistered[name]) {
|
|
4955
|
+
resolve(_a.isRegistered[name]);
|
|
4940
4956
|
}
|
|
4941
|
-
Observable.getNotifier(
|
|
4957
|
+
Observable.getNotifier(_a.isRegistered).subscribe({ handleChange: () => resolve(_a.isRegistered[name]) }, name);
|
|
4942
4958
|
});
|
|
4943
4959
|
});
|
|
4944
4960
|
Observable.defineProperty(FASTElementDefinition.prototype, "template");
|
|
@@ -5466,90 +5482,6 @@ let elementControllerStrategy;
|
|
|
5466
5482
|
* @public
|
|
5467
5483
|
*/
|
|
5468
5484
|
class ElementController extends PropertyChangeNotifier {
|
|
5469
|
-
/**
|
|
5470
|
-
* Creates a Controller to control the specified element.
|
|
5471
|
-
* @param element - The element to be controlled by this controller.
|
|
5472
|
-
* @param definition - The element definition metadata that instructs this
|
|
5473
|
-
* controller in how to handle rendering and other platform integrations.
|
|
5474
|
-
* @internal
|
|
5475
|
-
*/
|
|
5476
|
-
constructor(element, definition) {
|
|
5477
|
-
super(element);
|
|
5478
|
-
/**
|
|
5479
|
-
* A map of observable properties that were set on the element before upgrade.
|
|
5480
|
-
*/
|
|
5481
|
-
this.boundObservables = null;
|
|
5482
|
-
/**
|
|
5483
|
-
* Indicates whether the controller needs to perform initial rendering.
|
|
5484
|
-
*/
|
|
5485
|
-
this.needsInitialization = true;
|
|
5486
|
-
/**
|
|
5487
|
-
* Indicates whether the element has an existing shadow root (e.g. from declarative shadow DOM).
|
|
5488
|
-
*/
|
|
5489
|
-
this.hasExistingShadowRoot = false;
|
|
5490
|
-
/**
|
|
5491
|
-
* The template used to render the component.
|
|
5492
|
-
*/
|
|
5493
|
-
this._template = null;
|
|
5494
|
-
/**
|
|
5495
|
-
* The current lifecycle stage of the controller.
|
|
5496
|
-
*/
|
|
5497
|
-
this.stage = 3 /* Stages.disconnected */;
|
|
5498
|
-
/**
|
|
5499
|
-
* A guard against connecting behaviors multiple times
|
|
5500
|
-
* during connect in scenarios where a behavior adds
|
|
5501
|
-
* another behavior during it's connectedCallback
|
|
5502
|
-
*/
|
|
5503
|
-
this.guardBehaviorConnection = false;
|
|
5504
|
-
/**
|
|
5505
|
-
* The behaviors associated with the component.
|
|
5506
|
-
*/
|
|
5507
|
-
this.behaviors = null;
|
|
5508
|
-
/**
|
|
5509
|
-
* Tracks whether behaviors are connected so that
|
|
5510
|
-
* behaviors cant be connected multiple times
|
|
5511
|
-
*/
|
|
5512
|
-
this.behaviorsConnected = false;
|
|
5513
|
-
/**
|
|
5514
|
-
* The main set of styles used for the component, independent of any
|
|
5515
|
-
* dynamically added styles.
|
|
5516
|
-
*/
|
|
5517
|
-
this._mainStyles = null;
|
|
5518
|
-
/**
|
|
5519
|
-
* This allows Observable.getNotifier(...) to return the Controller
|
|
5520
|
-
* when the notifier for the Controller itself is being requested. The
|
|
5521
|
-
* result is that the Observable system does not need to create a separate
|
|
5522
|
-
* instance of Notifier for observables on the Controller. The component and
|
|
5523
|
-
* the controller will now share the same notifier, removing one-object construct
|
|
5524
|
-
* per web component instance.
|
|
5525
|
-
*/
|
|
5526
|
-
this.$fastController = this;
|
|
5527
|
-
/**
|
|
5528
|
-
* The view associated with the custom element.
|
|
5529
|
-
* @remarks
|
|
5530
|
-
* If `null` then the element is managing its own rendering.
|
|
5531
|
-
*/
|
|
5532
|
-
this.view = null;
|
|
5533
|
-
this.source = element;
|
|
5534
|
-
this.definition = definition;
|
|
5535
|
-
this.shadowOptions = definition.shadowOptions;
|
|
5536
|
-
// Capture any observable values that were set by the binding engine before
|
|
5537
|
-
// the browser upgraded the element. Then delete the property since it will
|
|
5538
|
-
// shadow the getter/setter that is required to make the observable operate.
|
|
5539
|
-
// Later, in the connect callback, we'll re-apply the values.
|
|
5540
|
-
const accessors = Observable.getAccessors(element);
|
|
5541
|
-
if (accessors.length > 0) {
|
|
5542
|
-
const boundObservables = (this.boundObservables = Object.create(null));
|
|
5543
|
-
for (let i = 0, ii = accessors.length; i < ii; ++i) {
|
|
5544
|
-
const propertyName = accessors[i].name;
|
|
5545
|
-
const value = element[propertyName];
|
|
5546
|
-
if (value !== void 0) {
|
|
5547
|
-
delete element[propertyName];
|
|
5548
|
-
boundObservables[propertyName] = value;
|
|
5549
|
-
}
|
|
5550
|
-
}
|
|
5551
|
-
}
|
|
5552
|
-
}
|
|
5553
5485
|
/**
|
|
5554
5486
|
* Indicates whether or not the custom element has been
|
|
5555
5487
|
* connected to the document.
|
|
@@ -5663,6 +5595,90 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
5663
5595
|
this.addStyles(value);
|
|
5664
5596
|
}
|
|
5665
5597
|
}
|
|
5598
|
+
/**
|
|
5599
|
+
* Creates a Controller to control the specified element.
|
|
5600
|
+
* @param element - The element to be controlled by this controller.
|
|
5601
|
+
* @param definition - The element definition metadata that instructs this
|
|
5602
|
+
* controller in how to handle rendering and other platform integrations.
|
|
5603
|
+
* @internal
|
|
5604
|
+
*/
|
|
5605
|
+
constructor(element, definition) {
|
|
5606
|
+
super(element);
|
|
5607
|
+
/**
|
|
5608
|
+
* A map of observable properties that were set on the element before upgrade.
|
|
5609
|
+
*/
|
|
5610
|
+
this.boundObservables = null;
|
|
5611
|
+
/**
|
|
5612
|
+
* Indicates whether the controller needs to perform initial rendering.
|
|
5613
|
+
*/
|
|
5614
|
+
this.needsInitialization = true;
|
|
5615
|
+
/**
|
|
5616
|
+
* Indicates whether the element has an existing shadow root (e.g. from declarative shadow DOM).
|
|
5617
|
+
*/
|
|
5618
|
+
this.hasExistingShadowRoot = false;
|
|
5619
|
+
/**
|
|
5620
|
+
* The template used to render the component.
|
|
5621
|
+
*/
|
|
5622
|
+
this._template = null;
|
|
5623
|
+
/**
|
|
5624
|
+
* The current lifecycle stage of the controller.
|
|
5625
|
+
*/
|
|
5626
|
+
this.stage = 3 /* Stages.disconnected */;
|
|
5627
|
+
/**
|
|
5628
|
+
* A guard against connecting behaviors multiple times
|
|
5629
|
+
* during connect in scenarios where a behavior adds
|
|
5630
|
+
* another behavior during it's connectedCallback
|
|
5631
|
+
*/
|
|
5632
|
+
this.guardBehaviorConnection = false;
|
|
5633
|
+
/**
|
|
5634
|
+
* The behaviors associated with the component.
|
|
5635
|
+
*/
|
|
5636
|
+
this.behaviors = null;
|
|
5637
|
+
/**
|
|
5638
|
+
* Tracks whether behaviors are connected so that
|
|
5639
|
+
* behaviors cant be connected multiple times
|
|
5640
|
+
*/
|
|
5641
|
+
this.behaviorsConnected = false;
|
|
5642
|
+
/**
|
|
5643
|
+
* The main set of styles used for the component, independent of any
|
|
5644
|
+
* dynamically added styles.
|
|
5645
|
+
*/
|
|
5646
|
+
this._mainStyles = null;
|
|
5647
|
+
/**
|
|
5648
|
+
* This allows Observable.getNotifier(...) to return the Controller
|
|
5649
|
+
* when the notifier for the Controller itself is being requested. The
|
|
5650
|
+
* result is that the Observable system does not need to create a separate
|
|
5651
|
+
* instance of Notifier for observables on the Controller. The component and
|
|
5652
|
+
* the controller will now share the same notifier, removing one-object construct
|
|
5653
|
+
* per web component instance.
|
|
5654
|
+
*/
|
|
5655
|
+
this.$fastController = this;
|
|
5656
|
+
/**
|
|
5657
|
+
* The view associated with the custom element.
|
|
5658
|
+
* @remarks
|
|
5659
|
+
* If `null` then the element is managing its own rendering.
|
|
5660
|
+
*/
|
|
5661
|
+
this.view = null;
|
|
5662
|
+
this.source = element;
|
|
5663
|
+
this.definition = definition;
|
|
5664
|
+
this.shadowOptions = definition.shadowOptions;
|
|
5665
|
+
// Capture any observable values that were set by the binding engine before
|
|
5666
|
+
// the browser upgraded the element. Then delete the property since it will
|
|
5667
|
+
// shadow the getter/setter that is required to make the observable operate.
|
|
5668
|
+
// Later, in the connect callback, we'll re-apply the values.
|
|
5669
|
+
const accessors = Observable.getAccessors(element);
|
|
5670
|
+
if (accessors.length > 0) {
|
|
5671
|
+
const boundObservables = (this.boundObservables = Object.create(null));
|
|
5672
|
+
for (let i = 0, ii = accessors.length; i < ii; ++i) {
|
|
5673
|
+
const propertyName = accessors[i].name;
|
|
5674
|
+
const value = element[propertyName];
|
|
5675
|
+
if (value !== void 0) {
|
|
5676
|
+
delete element[propertyName];
|
|
5677
|
+
boundObservables[propertyName] = value;
|
|
5678
|
+
}
|
|
5679
|
+
}
|
|
5680
|
+
}
|
|
5681
|
+
}
|
|
5666
5682
|
/**
|
|
5667
5683
|
* Registers an unbind handler with the controller.
|
|
5668
5684
|
* @param behavior - An object to call when the controller unbinds.
|