Skip to content

Commit 9d865ef

Browse files
Fix deprecation with path.original (#756)
1 parent bf983fe commit 9d865ef

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

htmlbars-plugins/v-get.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@ var plugin = function ({ syntax }) {
8383

8484
function processNode(node, syntax) {
8585
var type = node.type;
86-
node = unwrapNode(node);
8786

8887
// {{v-get model 'username' 'isValid'}}
89-
if (type === 'MustacheStatement' && node.path.original === 'v-get') {
88+
if (type === 'MustacheStatement' && getValue(node.path) === 'v-get') {
9089
transformToGet(node, syntax);
9190
}
9291

@@ -104,7 +103,7 @@ function processNodeParams(node, syntax) {
104103
for (var i = 0; i < node.params.length; i++) {
105104
var param = node.params[i];
106105
if (param.type === 'SubExpression') {
107-
if (param.path.original === 'v-get') {
106+
if (getValue(param.path) === 'v-get') {
108107
transformToGet(param, syntax);
109108
} else {
110109
processNode(param, syntax);
@@ -123,7 +122,7 @@ function processNodeHash(node, syntax) {
123122
for (var i = 0; i < node.hash.pairs.length; i++) {
124123
var pair = node.hash.pairs[i];
125124
if (pair.value.type === 'SubExpression') {
126-
if (pair.value.path.original === 'v-get') {
125+
if (getValue(pair.value.path) === 'v-get') {
127126
transformToGet(pair.value, syntax);
128127
} else {
129128
processNode(pair.value, syntax);
@@ -163,7 +162,6 @@ function processNodeAttributes(node, syntax) {
163162
* @return {AST.Node}
164163
*/
165164
function transformToGet(node, syntax) {
166-
node = unwrapNode(node);
167165
var params = node.params;
168166
var numParams = params.length;
169167

@@ -197,13 +195,18 @@ function transformToGet(node, syntax) {
197195
node.params = [root, params[numParams - 1]];
198196
}
199197

200-
// For compatibility with pre- and post-glimmer
201-
function unwrapNode(node) {
202-
if (node.sexpr) {
203-
return node.sexpr;
204-
} else {
205-
return node;
198+
function getValue(path) {
199+
if (!path) return;
200+
201+
if ('value' in path) {
202+
return path.value;
206203
}
204+
205+
/**
206+
* Deprecated in ember 5.9+
207+
* (so we use the above for newer embers)
208+
*/
209+
return path.original;
207210
}
208211

209212
module.exports = plugin;

0 commit comments

Comments
 (0)