Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// A Polymer 2.0 class-based element
const getter = jsc.methodDefinition(
'get',
jsc.identifier('importMeta'),
jsc.functionExpression(
null,
[],
jsc.blockStatement([jsc.returnStatement(importMeta)])),
true);
node.body.body.splice(0, 0, getter);
} else if (node.type === 'CallExpression') {
// A Polymer hybrid/legacy factory function element
const arg = node.arguments[0];
if (arg && arg.type === 'ObjectExpression') {
arg.properties.unshift(
jsc.property('init', jsc.identifier('importMeta'), importMeta));
}
} else {
console.error(`Internal Error, Class or CallExpression expected, got ${
node.type}`);
}
}
}
// A Polymer 2.0 class-based element
node.body.body.splice(
0,
0,
jsc.methodDefinition(
'get',
jsc.identifier('template'),
jsc.functionExpression(
null, [], jsc.blockStatement([jsc.returnStatement(
templateLiteral)])),
true));
} else if (node.type === 'CallExpression') {
// A Polymer hybrid/legacy factory function element
const arg = node.arguments[0];
if (arg && arg.type === 'ObjectExpression') {
arg.properties.unshift(jsc.property(
'init', jsc.identifier('_template'), templateLiteral));
}
} else {
console.error(`Internal Error, Class or CallExpression expected, got ${
node.type}`);
}
}
return claimedDomModules;
}
function appendActionCreatorFunction({ast, constantName, actionCreatorName}) {
const newFunction = j.functionDeclaration(j.identifier(actionCreatorName), [], j.blockStatement([
j.returnStatement(
j.objectExpression([
j.property('init', j.literal('type'), j.identifier(constantName)),
])
),
]))
const newExport = j.exportNamedDeclaration(newFunction, [], null)
const exports = ast
.find(j.ExportNamedDeclaration)
exports
.at(exports.length - 1)
.insertAfter(newExport)
}
Object.keys(obj).forEach((key, index) => {
const existingProperty = findPropertyByKey(node.properties, key)
if (existingProperty) {
existingProperty.value = writeValue(existingProperty.value, obj[key])
newProperties.push(existingProperty)
} else {
if (obj[key] === undefined) return
const newKey = getNewPropertyKey(node.properties, key)
const newValue = writeValue(undefined, obj[key])
const newProperty = j.property('init', newKey, newValue)
newProperties.push(newProperty)
}
})
node.properties = newProperties
`_addModelItem: ${itemsKey} should be ObjectExpression, but got ${prop.value.type}`
);
items = prop;
}
});
if (!items) {
items = j.property(
'init',
j.identifier(itemsKey),
j.objectExpression([])
);
path.node.properties.push(items);
}
const item = j.property(
'init',
j.identifier(name),
utils.getExpression(source || defaultSource)
);
items.value.properties.push(item);
});
},
return this.forEach(path => {
let items = null;
path.node.properties.forEach(prop => {
if (j.Property.check(prop) && prop.key.name === itemsKey) {
assert(
j.ObjectExpression.check(prop.value),
`_addModelItem: ${itemsKey} should be ObjectExpression, but got ${prop.value.type}`
);
items = prop;
}
});
if (!items) {
items = j.property(
'init',
j.identifier(itemsKey),
j.objectExpression([])
);
path.node.properties.push(items);
}
const item = j.property(
'init',
j.identifier(name),
utils.getExpression(source || defaultSource)
);
items.value.properties.push(item);
});
},