Skip to content

Commit

Permalink
fix(theme): expose version property (#3978)
Browse files Browse the repository at this point in the history
* fix: expose version property on theme

* fix: add unit test for theme version
  • Loading branch information
jcmitch committed Jan 31, 2024
1 parent 3528572 commit d42bb71
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/theme/src/Theme.ts
Expand Up @@ -15,6 +15,7 @@ import {
CSSResultGroup,
supportsAdoptingStyleSheets,
} from '@spectrum-web-components/base';
import { version } from '@spectrum-web-components/base/src/version.js';

declare global {
interface Window {
Expand Down Expand Up @@ -95,6 +96,7 @@ export class Theme extends HTMLElement implements ThemeKindProvider {
private static defaultFragments: Set<FragmentName> = new Set(['spectrum']);
private static templateElement?: HTMLTemplateElement;
private static instances: Set<Theme> = new Set();
static VERSION = version;

static get observedAttributes(): string[] {
return ['color', 'scale', 'theme', 'lang', 'dir'];
Expand Down
23 changes: 23 additions & 0 deletions tools/theme/test/theme.test.ts
@@ -0,0 +1,23 @@
/*
Copyright 2020 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
import { Theme } from '@spectrum-web-components/theme';
import { expect } from '@open-wc/testing';
import { version } from '@spectrum-web-components/base/src/version.js';

class DirElement extends Theme {}

customElements.define('dir-element', DirElement);

describe('Theme', () => {
it('has a static VERSION property', () => {
expect(DirElement.VERSION).to.equal(version);
});
});

0 comments on commit d42bb71

Please sign in to comment.