@vaadin/vaadin-themable-mixin 23.1.0-alpha2 → 23.1.0-beta1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/vaadin-themable-mixin",
3
- "version": "23.1.0-alpha2",
3
+ "version": "23.1.0-beta1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,7 +38,7 @@
38
38
  "@esm-bundle/chai": "^4.3.4",
39
39
  "@polymer/polymer": "^3.0.0",
40
40
  "@vaadin/testing-helpers": "^0.3.2",
41
- "sinon": "^9.2.4"
41
+ "sinon": "^13.0.2"
42
42
  },
43
- "gitHead": "6842dcb8b163d4512fae8d3d12a6559077a4aee6"
43
+ "gitHead": "8be43cf83102a6b9ccf309687446e590ce0164e8"
44
44
  }
@@ -11,7 +11,7 @@ import { ThemePropertyMixinClass } from './vaadin-theme-property-mixin.js';
11
11
  * A mixin for `nav` elements, facilitating navigation and selection of childNodes.
12
12
  */
13
13
  export declare function ThemableMixin<T extends Constructor<HTMLElement>>(
14
- base: T
14
+ base: T,
15
15
  ): T & Constructor<ThemableMixinClass> & Constructor<ThemePropertyMixinClass>;
16
16
 
17
17
  export declare class ThemableMixinClass {
@@ -52,7 +52,7 @@ export function registerStyles(themeFor, styles, options = {}) {
52
52
  themeFor,
53
53
  styles,
54
54
  include: options.include,
55
- moduleId: options.moduleId
55
+ moduleId: options.moduleId,
56
56
  });
57
57
  }
58
58
  }
@@ -77,7 +77,7 @@ function getAllThemes() {
77
77
  */
78
78
  function matchesThemeFor(themeFor, tagName) {
79
79
  return (themeFor || '').split(' ').some((themeForToken) => {
80
- return new RegExp('^' + themeForToken.split('*').join('.*') + '$').test(tagName);
80
+ return new RegExp(`^${themeForToken.split('*').join('.*')}$`).test(tagName);
81
81
  });
82
82
  }
83
83
 
@@ -151,7 +151,7 @@ function addStylesToTemplate(styles, template) {
151
151
  * @returns {Theme[]}
152
152
  */
153
153
  function getThemes(tagName) {
154
- const defaultModuleName = tagName + '-default-theme';
154
+ const defaultModuleName = `${tagName}-default-theme`;
155
155
 
156
156
  const themes = getAllThemes()
157
157
  // Filter by matching themeFor properties
@@ -161,7 +161,7 @@ function getThemes(tagName) {
161
161
  // Prepend styles from included themes
162
162
  styles: [...getIncludedStyles(theme), ...theme.styles],
163
163
  // Map moduleId to includePriority
164
- includePriority: getIncludePriority(theme.moduleId)
164
+ includePriority: getIncludePriority(theme.moduleId),
165
165
  }))
166
166
  // Sort by includePriority
167
167
  .sort((themeA, themeB) => themeB.includePriority - themeA.includePriority);
@@ -179,7 +179,15 @@ function getThemes(tagName) {
179
179
  * @returns {boolean}
180
180
  */
181
181
  function hasThemes(tagName) {
182
- const elementClass = customElements.get(tagName);
182
+ return classHasThemes(customElements.get(tagName));
183
+ }
184
+
185
+ /**
186
+ * Check if the custom element type has themes applied.
187
+ * @param {Function} elementClass
188
+ * @returns {boolean}
189
+ */
190
+ function classHasThemes(elementClass) {
183
191
  return elementClass && Object.prototype.hasOwnProperty.call(elementClass, '__themes');
184
192
  }
185
193
 
@@ -196,8 +204,13 @@ export const ThemableMixin = (superClass) =>
196
204
  static finalize() {
197
205
  super.finalize();
198
206
 
207
+ // Make sure not to run the logic intended for PolymerElement when LitElement is used.
208
+ if (this.elementStyles) {
209
+ return;
210
+ }
211
+
199
212
  const template = this.prototype._template;
200
- if (!template || hasThemes(this.is)) {
213
+ if (!template || classHasThemes(this)) {
201
214
  return;
202
215
  }
203
216
 
@@ -6,7 +6,7 @@
6
6
  import { Constructor } from '@open-wc/dedupe-mixin';
7
7
 
8
8
  export declare function ThemePropertyMixin<T extends Constructor<HTMLElement>>(
9
- base: T
9
+ base: T,
10
10
  ): T & Constructor<ThemePropertyMixinClass>;
11
11
 
12
12
  export declare class ThemePropertyMixinClass {
@@ -32,7 +32,7 @@ export const ThemePropertyMixin = (superClass) =>
32
32
  theme: {
33
33
  type: String,
34
34
  reflectToAttribute: true,
35
- observer: '__deprecatedThemePropertyChanged'
35
+ observer: '__deprecatedThemePropertyChanged',
36
36
  },
37
37
 
38
38
  /**
@@ -54,8 +54,8 @@ export const ThemePropertyMixin = (superClass) =>
54
54
  */
55
55
  _theme: {
56
56
  type: String,
57
- readOnly: true
58
- }
57
+ readOnly: true,
58
+ },
59
59
  };
60
60
  }
61
61