|
|
@ -7,10 +7,11 @@ export default function flatten_reference(node: Node) {
|
|
|
|
const prop_end = node.end;
|
|
|
|
const prop_end = node.end;
|
|
|
|
|
|
|
|
|
|
|
|
while (node.type === 'MemberExpression') {
|
|
|
|
while (node.type === 'MemberExpression') {
|
|
|
|
if (node.computed) return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nodes.unshift(node.property);
|
|
|
|
nodes.unshift(node.property);
|
|
|
|
parts.unshift(node.property.name);
|
|
|
|
|
|
|
|
|
|
|
|
if (!node.computed) {
|
|
|
|
|
|
|
|
parts.unshift(node.property.name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
node = node.object;
|
|
|
|
node = node.object;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -20,10 +21,12 @@ export default function flatten_reference(node: Node) {
|
|
|
|
? node.name
|
|
|
|
? node.name
|
|
|
|
: node.type === 'ThisExpression' ? 'this' : null;
|
|
|
|
: node.type === 'ThisExpression' ? 'this' : null;
|
|
|
|
|
|
|
|
|
|
|
|
if (!name) return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parts.unshift(name);
|
|
|
|
|
|
|
|
nodes.unshift(node);
|
|
|
|
nodes.unshift(node);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!node.computed) {
|
|
|
|
|
|
|
|
parts.unshift(name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return { name, nodes, parts, keypath: `${name}[✂${prop_start}-${prop_end}✂]` };
|
|
|
|
return { name, nodes, parts, keypath: `${name}[✂${prop_start}-${prop_end}✂]` };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|