Skip to content

Commit a274e81

Browse files
committed
use last value
this is the correct thing
1 parent de96fb2 commit a274e81

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

ember_debug/object-inspector.js

+17-15
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function isMandatorySetter(descriptor) {
209209
return false;
210210
}
211211

212-
function getTagTrackedProps(tag, ownTag, level = 0) {
212+
function getTagTrackedTags(tag, ownTag, level = 0) {
213213
const props = [];
214214
// do not include tracked properties from dependencies
215215
if (!tag || level > 1) {
@@ -219,13 +219,13 @@ function getTagTrackedProps(tag, ownTag, level = 0) {
219219
if (tag.subtag && !Array.isArray(tag.subtag)) {
220220
if (tag.subtag._propertyKey) props.push(tag.subtag);
221221

222-
props.push(...getTagTrackedProps(tag.subtag, ownTag, level + 1));
222+
props.push(...getTagTrackedTags(tag.subtag, ownTag, level + 1));
223223
}
224224
if (subtags) {
225225
subtags.forEach((t) => {
226226
if (t === ownTag) return;
227227
if (t._propertyKey) props.push(t);
228-
props.push(...getTagTrackedProps(t, ownTag, level + 1));
228+
props.push(...getTagTrackedTags(t, ownTag, level + 1));
229229
});
230230
}
231231
return props;
@@ -244,21 +244,22 @@ function getTrackedDependencies(object, property, tagInfo) {
244244
}
245245
if (HAS_GLIMMER_TRACKING) {
246246
const ownTag = tagForProperty(object, property);
247-
const props = getTagTrackedProps(tag, ownTag);
247+
const tags = getTagTrackedTags(tag, ownTag);
248248
const mapping = {};
249-
let maxRevision = tagInfo.revision ?? 0;
250-
let minRevision = Infinity;
251-
props.forEach((t) => {
249+
let maxRevision = tagValue(tag);
250+
tags.forEach((t) => {
252251
const p =
253252
(t._object ? getObjectName(t._object) + '.' : '') + t._propertyKey;
254-
const [objName, ...props] = p.split('.');
253+
const [objName, prop] = p.split('.');
255254
mapping[objName] = mapping[objName] || new Set();
256-
maxRevision = Math.max(maxRevision, t.revision);
257-
minRevision = Math.min(minRevision, t.revision);
258-
props.forEach((p) => mapping[objName].add([p, t.revision]));
255+
const value = tagValue(t);
256+
if (prop) {
257+
mapping[objName].add([prop, value]);
258+
}
259259
});
260260

261-
const hasChange = maxRevision !== minRevision;
261+
const hasChange =
262+
(tagInfo.revision && maxRevision !== tagInfo.revision) || false;
262263

263264
const names = new Set();
264265

@@ -270,7 +271,7 @@ function getTrackedDependencies(object, property, tagInfo) {
270271
if (props.size > 1) {
271272
dependentKeys.push({ name: objName });
272273
props.forEach((p) => {
273-
const changed = hasChange && p[1] >= maxRevision;
274+
const changed = hasChange && p[1] > tagInfo.revision;
274275
const obj = {
275276
child: p[0],
276277
};
@@ -282,7 +283,7 @@ function getTrackedDependencies(object, property, tagInfo) {
282283
}
283284
if (props.size === 1) {
284285
const p = [...props][0];
285-
const changed = hasChange && p[1] >= maxRevision;
286+
const changed = hasChange && p[1] > tagInfo.revision;
286287
const obj = {
287288
name: objName + '.' + p[0],
288289
};
@@ -1137,7 +1138,8 @@ function calculateCPs(
11371138
if (cache !== undefined || !item.isExpensive) {
11381139
let value;
11391140
if (item.canTrack && HAS_GLIMMER_TRACKING) {
1140-
const tagInfo = (tracked[item.name] = {});
1141+
tracked[item.name] = tracked[item.name] || {};
1142+
const tagInfo = tracked[item.name];
11411143
tagInfo.tag = track(() => {
11421144
value = calculateCP(object, item, errorsForObject);
11431145
});

0 commit comments

Comments
 (0)