Skip to content

Commit

Permalink
add UNKNOWN_PROPERTY_TAG
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Garrett committed Apr 19, 2019
1 parent 69262f3 commit bd39c46
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/@ember/-internals/metal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export {
} from './lib/descriptor_map';
export { watchKey, unwatchKey } from './lib/watch_key';
export { ChainNode, finishChains, removeChainWatcher } from './lib/chains';
export { getChainTagsForKey } from './lib/chain-tags';
export { watchPath, unwatchPath } from './lib/watch_path';
export { isWatching, unwatch, watch, watcherCount } from './lib/watching';
export { default as libraries, Libraries } from './lib/libraries';
Expand All @@ -53,7 +54,7 @@ export {
} from './lib/observer';
export { Mixin, aliasMethod, mixin, observer, applyMixin } from './lib/mixin';
export { default as inject, DEBUG_INJECTION_FUNCTIONS } from './lib/injected_property';
export { tagForProperty, tagFor, markObjectAsDirty } from './lib/tags';
export { tagForProperty, tagFor, markObjectAsDirty, UNKNOWN_PROPERTY_TAG } from './lib/tags';
export { default as runInTransaction, didRender, assertNotRendered } from './lib/transaction';
export { Tracker, tracked, getCurrentTracker, setCurrentTracker } from './lib/tracked';

Expand Down
10 changes: 8 additions & 2 deletions packages/@ember/-internals/metal/lib/tags.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Meta, meta as metaFor } from '@ember/-internals/meta';
import { isProxy } from '@ember/-internals/utils';
import { isProxy, symbol } from '@ember/-internals/utils';
import { EMBER_METAL_TRACKED_PROPERTIES } from '@ember/canary-features';
import { backburner } from '@ember/runloop';
import { DEBUG } from '@glimmer/env';
Expand All @@ -12,6 +12,8 @@ import {
UpdatableTag,
} from '@glimmer/reference';

export const UNKNOWN_PROPERTY_TAG = symbol('UNKNOWN_PROPERTY_TAG');

function makeTag(): TagWrapper<DirtyableTag> {
return DirtyableTag.create();
}
Expand All @@ -23,7 +25,11 @@ export function tagForProperty(object: any, propertyKey: string | symbol, _meta?
}
let meta = _meta === undefined ? metaFor(object) : _meta;

if (isProxy(object)) {
if (EMBER_METAL_TRACKED_PROPERTIES) {
if (!(propertyKey in object) && typeof object[UNKNOWN_PROPERTY_TAG] === 'function') {
return object[UNKNOWN_PROPERTY_TAG](propertyKey);
}
} else if (isProxy(object)) {
return tagFor(object, meta);
}

Expand Down
6 changes: 6 additions & 0 deletions packages/@ember/-internals/runtime/lib/mixins/-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
Mixin,
tagFor,
computed,
UNKNOWN_PROPERTY_TAG,
getChainTagsForKey,
} from '@ember/-internals/metal';
import { setProxy } from '@ember/-internals/utils';
import { EMBER_METAL_TRACKED_PROPERTIES } from '@ember/canary-features';
Expand Down Expand Up @@ -85,6 +87,10 @@ export default Mixin.create({
}
},

[UNKNOWN_PROPERTY_TAG](key) {
return getChainTagsForKey(this, `content.${key}`);
},

unknownProperty(key) {
let content = contentFor(this);
if (content) {
Expand Down

0 comments on commit bd39c46

Please sign in to comment.