diff --git a/client-src/elements/chromedash-feature.js b/client-src/elements/chromedash-feature.ts similarity index 93% rename from client-src/elements/chromedash-feature.js rename to client-src/elements/chromedash-feature.ts index b3bf416d..a74fffb6 100644 --- a/client-src/elements/chromedash-feature.js +++ b/client-src/elements/chromedash-feature.ts @@ -6,30 +6,39 @@ import './chromedash-color-status'; import {FEATURE_CSS} from '../css/elements/chromedash-feature-css.js'; import {SHARED_STYLES} from '../css/shared-css.js'; +import {customElement, property, state} from 'lit/decorators.js'; +import {Feature} from '../js-src/cs-client.js'; const MAX_STANDARDS_VAL = 5; const MAX_VENDOR_VIEW = 7; const MAX_WEBDEV_VIEW = 6; +@customElement('chromedash-feature') class ChromedashFeature extends LitElement { static styles = FEATURE_CSS; - - static get properties() { - return { - feature: {type: Object}, - canEdit: {type: Boolean}, - signedin: {type: Boolean}, - open: {type: Boolean, reflect: true}, // Attribute used in the parent for styling - starred: {type: Boolean}, - // Values used in the template - _isDeprecated: {attribute: false}, - _hasDocLinks: {attribute: false}, - _hasSampleLinks: {attribute: false}, - _commentHtml: {attribute: false}, - _crBugNumber: {attribute: false}, - _newBugUrl: {attribute: false}, - }; - } + @property({type: Object}) + feature!: Feature; + @property({type: Boolean}) + canEdit; + @property({type: Boolean}) + signedin; + @property({type: Boolean, reflect: true}) + open; + @property({type: Boolean}) + starred; + // Values used in the template + @state() + _isDeprecated; + @state() + _hasDocLinks; + @state() + _hasSampleLinks; + @state() + _commentHtml; + @state() + _crBugNumber; + @state() + _newBugUrl; firstUpdated() { this._initializeValues(); @@ -75,7 +84,7 @@ class ChromedashFeature extends LitElement { const url = 'https://bugs.chromium.org/p/chromium/issues/entry'; const params = [ `components=${ - this.feature.browsers.chrome.blink_components[0] || 'Blink' + this.feature.browsers.chrome.blink_components?.[0] || 'Blink' }`, ]; if (this._crBugNumber && this._getIsPreLaunch()) { @@ -99,14 +108,14 @@ class ChromedashFeature extends LitElement { 'On hold', ]; return PRE_LAUNCH_STATUSES.includes( - this.feature.browsers.chrome.status.text + this.feature.browsers.chrome.status.text ?? '' ); } _getIsDeprecated() { const DEPRECATED_STATUSES = ['Deprecated', 'No longer pursuing']; return DEPRECATED_STATUSES.includes( - this.feature.browsers.chrome.status.text + this.feature.browsers.chrome.status.text ?? '' ); } @@ -144,8 +153,8 @@ class ChromedashFeature extends LitElement { target.tagName == 'A' || target.tagName == 'CHROMEDASH-MULTI-LINKS' || e.composedPath()[0].nodeName === 'A' || - textSelection.type === 'RANGE' || - textSelection.toString() + textSelection?.type === 'RANGE' || + textSelection?.toString() ) { return; } @@ -466,15 +475,15 @@ class ChromedashFeature extends LitElement {