@vaadin/component-base 24.2.0-alpha3 → 24.2.0-alpha5
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/package.json +3 -3
- package/src/controller-mixin.js +55 -50
- package/src/element-mixin.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/component-base",
|
|
3
|
-
"version": "24.2.0-
|
|
3
|
+
"version": "24.2.0-alpha5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@esm-bundle/chai": "^4.3.4",
|
|
42
|
-
"@vaadin/testing-helpers": "^0.4.
|
|
42
|
+
"@vaadin/testing-helpers": "^0.4.3",
|
|
43
43
|
"sinon": "^13.0.2"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "73db22a5e8993e3ce48d1e6540d30eff9cb5c257"
|
|
46
46
|
}
|
package/src/controller-mixin.js
CHANGED
|
@@ -15,62 +15,67 @@ import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
|
|
|
15
15
|
*
|
|
16
16
|
* @polymerMixin
|
|
17
17
|
*/
|
|
18
|
-
export const ControllerMixin = dedupingMixin(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
export const ControllerMixin = dedupingMixin((superClass) => {
|
|
19
|
+
// If the superclass extends from LitElement,
|
|
20
|
+
// use its own controllers implementation.
|
|
21
|
+
if (typeof superClass.prototype.addController === 'function') {
|
|
22
|
+
return superClass;
|
|
23
|
+
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.__controllers = new Set();
|
|
28
|
-
}
|
|
25
|
+
return class ControllerMixinClass extends superClass {
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
29
28
|
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
/**
|
|
30
|
+
* @type {Set<ReactiveController>}
|
|
31
|
+
*/
|
|
32
|
+
this.__controllers = new Set();
|
|
33
|
+
}
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
35
|
+
/** @protected */
|
|
36
|
+
connectedCallback() {
|
|
37
|
+
super.connectedCallback();
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
this.__controllers.forEach((c) => {
|
|
40
|
+
if (c.hostConnected) {
|
|
41
|
+
c.hostConnected();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
46
|
+
/** @protected */
|
|
47
|
+
disconnectedCallback() {
|
|
48
|
+
super.disconnectedCallback();
|
|
51
49
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
* @param {ReactiveController} controller
|
|
56
|
-
* @protected
|
|
57
|
-
*/
|
|
58
|
-
addController(controller) {
|
|
59
|
-
this.__controllers.add(controller);
|
|
60
|
-
// Call hostConnected if a controller is added after the element is attached.
|
|
61
|
-
if (this.$ !== undefined && this.isConnected && controller.hostConnected) {
|
|
62
|
-
controller.hostConnected();
|
|
50
|
+
this.__controllers.forEach((c) => {
|
|
51
|
+
if (c.hostDisconnected) {
|
|
52
|
+
c.hostDisconnected();
|
|
63
53
|
}
|
|
64
|
-
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
65
56
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Registers a controller to participate in the element update cycle.
|
|
59
|
+
*
|
|
60
|
+
* @param {ReactiveController} controller
|
|
61
|
+
* @protected
|
|
62
|
+
*/
|
|
63
|
+
addController(controller) {
|
|
64
|
+
this.__controllers.add(controller);
|
|
65
|
+
// Call hostConnected if a controller is added after the element is attached.
|
|
66
|
+
if (this.$ !== undefined && this.isConnected && controller.hostConnected) {
|
|
67
|
+
controller.hostConnected();
|
|
74
68
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Removes a controller from the element.
|
|
73
|
+
*
|
|
74
|
+
* @param {ReactiveController} controller
|
|
75
|
+
* @protected
|
|
76
|
+
*/
|
|
77
|
+
removeController(controller) {
|
|
78
|
+
this.__controllers.delete(controller);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
});
|
package/src/element-mixin.js
CHANGED