Skip to content

Commit

Permalink
[BUGFIX release] Restore previous hash behavior
Browse files Browse the repository at this point in the history
Restores the previous hash behavior where `hash` will lazily update in
templates, but eagerly evaluate and create a POJO in JS. Also preserves
the deprecation on setting on the hash.
  • Loading branch information
Chris Garrett committed Jul 26, 2021
1 parent fc09fef commit a23c71e
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 157 deletions.
24 changes: 12 additions & 12 deletions package.json
Expand Up @@ -50,7 +50,7 @@
"@babel/helper-module-imports": "^7.8.3",
"@babel/plugin-transform-block-scoping": "^7.8.3",
"@ember/edition-utils": "^1.2.0",
"@glimmer/vm-babel-plugins": "0.79.4",
"@glimmer/vm-babel-plugins": "0.80.0",
"babel-plugin-debug-macros": "^0.3.3",
"babel-plugin-filter-imports": "^4.0.0",
"broccoli-concat": "^4.2.4",
Expand All @@ -75,19 +75,19 @@
},
"devDependencies": {
"@babel/preset-env": "^7.9.5",
"@glimmer/compiler": "0.79.4",
"@glimmer/destroyable": "0.79.4",
"@glimmer/compiler": "0.80.0",
"@glimmer/destroyable": "0.80.0",
"@glimmer/env": "^0.1.7",
"@glimmer/global-context": "0.79.4",
"@glimmer/interfaces": "0.79.4",
"@glimmer/manager": "0.79.4",
"@glimmer/node": "0.79.4",
"@glimmer/opcode-compiler": "0.79.4",
"@glimmer/global-context": "0.80.0",
"@glimmer/interfaces": "0.80.0",
"@glimmer/manager": "0.80.0",
"@glimmer/node": "0.80.0",
"@glimmer/opcode-compiler": "0.80.0",
"@glimmer/owner": "0.80.0",
"@glimmer/program": "0.79.4",
"@glimmer/reference": "0.79.4",
"@glimmer/runtime": "0.79.4",
"@glimmer/validator": "0.79.4",
"@glimmer/program": "0.80.0",
"@glimmer/reference": "0.80.0",
"@glimmer/runtime": "0.80.0",
"@glimmer/validator": "0.80.0",
"@simple-dom/document": "^1.4.0",
"@types/qunit": "^2.11.1",
"@types/rsvp": "^4.0.3",
Expand Down
Expand Up @@ -255,7 +255,10 @@ moduleFor(

runTask(() => {
set(this.context, 'firstName', 'Godfrey');
});

// needs to be separate task because of the way classic components update args
runTask(() => {
expectDeprecation(() => {
set(instance.hash, 'lastName', 'Chan');
}, /You set the '.*' property on a {{hash}} object/);
Expand Down
27 changes: 16 additions & 11 deletions packages/@ember/-internals/metal/lib/chain-tags.ts
@@ -1,7 +1,6 @@
import { Meta, meta as metaFor, peekMeta } from '@ember/-internals/meta';
import { isObject } from '@ember/-internals/utils';
import { assert, deprecate } from '@ember/debug';
import { isHashProxy } from '@glimmer/runtime';
import { _WeakSet } from '@glimmer/util';
import {
combine,
Expand All @@ -17,7 +16,7 @@ import { tagForProperty } from './tags';

export const CHAIN_PASS_THROUGH = new _WeakSet();

export function finishLazyChains(meta: Meta, key: string, value: unknown): void {
export function finishLazyChains(meta: Meta, key: string, value: any) {
let lazyTags = meta.readableLazyChainsFor(key);

if (lazyTags === undefined) {
Expand Down Expand Up @@ -174,6 +173,20 @@ function getChainTags(

chainTags.push(propertyTag);

// If we're at the end of the path, processing the last segment, and it's
// not an alias, we should _not_ get the last value, since we already have
// its tag. There's no reason to access it and do more work.
if (segmentEnd === pathLength) {
// If the key was an alias, we should always get the next value in order to
// bootstrap the alias. This is because aliases, unlike other CPs, should
// always be in sync with the aliased value.
if (CHAIN_PASS_THROUGH.has(descriptor)) {
// tslint:disable-next-line: no-unused-expression
current[segment];
}
break;
}

if (descriptor === undefined) {
// If the descriptor is undefined, then its a normal property, so we should
// lookup the value to chain off of like normal.
Expand Down Expand Up @@ -210,16 +223,8 @@ function getChainTags(
}
}

if (segmentEnd === pathLength || !isObject(current)) {
if (!isObject(current)) {
// we've hit the end of the chain for now, break out

// If the last value is a HashProxy, then entangle all of its tags
if (isHashProxy(current)) {
for (let key in current) {
chainTags.push(tagForProperty(current, key));
}
}

break;
}

Expand Down

0 comments on commit a23c71e

Please sign in to comment.