Skip to content

Commit

Permalink
Ensure telemetry system works with legacyNoObservedAttributes setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Jan 29, 2020
1 parent 3e6ba3e commit 63addd3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/legacy/legacy-element-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { wrap } from '../utils/wrap.js';
import { scopeSubtree } from '../utils/scope-subtree.js';
import { legacyOptimizations, legacyNoObservedAttributes } from '../utils/settings.js';
import { findObservedAttributesGetter } from '../mixins/disable-upgrade-mixin.js';
import { register } from '../utils/telemetry.js';

const DISABLED_ATTR = 'disable-upgrade';

Expand Down Expand Up @@ -165,8 +166,16 @@ export const LegacyElementMixin = dedupingMixin((base) => {

// NOTE: Inlined for perf from version of DisableUpgradeMixin.
static get observedAttributes() {
return legacyNoObservedAttributes ? [] :
observedAttributesGetter.call(this).concat(DISABLED_ATTR);
if (legacyNoObservedAttributes) {
// Ensure this element is property registered with the telemetry system.
if (!this.hasOwnProperty(JSCompiler_renameProperty('__observedAttributes', this))) {
this.__observedAttributes = [];
register(this.prototype);
}
return this.__observedAttributes;
} else {
return observedAttributesGetter.call(this).concat(DISABLED_ATTR);
}
}

// NOTE: Inlined for perf from version of DisableUpgradeMixin.
Expand Down
6 changes: 6 additions & 0 deletions test/unit/legacy-noattributes.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
<script type="module">
import {flush} from '../../lib/utils/flush.js';
import {wrap} from '../../lib/utils/wrap.js';
import {registrations} from '../../lib/utils/telemetry.js';

suite('legacyNoObservedAttributes', () => {

Expand All @@ -100,6 +101,11 @@
el = fixture('declarative');
});

test('telemetry collected as expected', () => {
const def = registrations.find((def) => def.is === el.localName);
assert.ok(def);
});

test('static attributes', () => {
assert.equal(el.foo, 'foo');
assert.equal(el.$.child1.getAttribute('foo'), 'x-attrs.foo');
Expand Down

0 comments on commit 63addd3

Please sign in to comment.