Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
on,
forKey,
locator,
lwc,
} = element;
// Class attibute defined via string
if (className) {
const { expression: classExpression } = bindExpression(className, element);
data.push(t.objectProperty(t.identifier('className'), classExpression));
}
// Class attribute defined via object
if (classMap) {
const classMapObj = objectToAST(classMap, () => t.booleanLiteral(true));
data.push(t.objectProperty(t.identifier('classMap'), classMapObj));
}
// Style attribute defined via object
if (styleMap) {
const styleObj = objectToAST(styleMap, key =>
typeof styleMap[key] === 'number'
? t.numericLiteral(styleMap[key] as number)
: t.stringLiteral(styleMap[key] as string)
);
data.push(t.objectProperty(t.identifier('styleMap'), styleObj));
}
// Style attribute defined via string
if (style) {
const { expression: styleExpression } = bindExpression(style, element);
lwc,
} = element;
// Class attibute defined via string
if (className) {
const { expression: classExpression } = bindExpression(
className,
element,
);
data.push(t.objectProperty(t.identifier('className'), classExpression));
}
// Class attribute defined via object
if (classMap) {
const classMapObj = objectToAST(classMap, () => t.booleanLiteral(true));
data.push(t.objectProperty(t.identifier('classMap'), classMapObj));
}
// Style attribute defined via object
if (styleMap) {
const styleObj = objectToAST(
styleMap,
key =>
typeof styleMap[key] === 'number'
? t.numericLiteral(styleMap[key] as number)
: t.stringLiteral(styleMap[key] as string),
);
data.push(t.objectProperty(t.identifier('styleMap'), styleObj));
}
// Style attribute defined via string
});
const lwcObj = t.objectProperty(t.identifier('lwc'), t.objectExpression(lwcObject));
contextExpressions.push(lwcObj);
}
// Locators
if (locator) {
const locatorObject: t.ObjectProperty[] = [];
const locatorId = t.objectProperty(t.identifier('id') , t.stringLiteral(locator.id));
locatorObject.push(locatorId);
if (locator.context) {
let locatorContextFunction = bindExpression(locator.context, element).expression;
locatorContextFunction = codeGen.genFunctionBind(locatorContextFunction);
locatorContextFunction = memorizeHandler(codeGen, element, locator.context, locatorContextFunction);
locatorObject.push(t.objectProperty(t.identifier('context'), locatorContextFunction));
}
const contextObj = t.objectProperty(t.identifier('locator'), t.objectExpression(locatorObject));
contextExpressions.push(contextObj);
}
data.push(t.objectProperty(t.identifier('context'), t.objectExpression(contextExpressions)));
}
t.objectPattern(
newParams.map(param =>
t.objectProperty(
t.identifier(param),
t.identifier(param),
false,
true,
),
),
),
];
} else {
path.node.params = [
//@ts-ignore
t.objectPattern([
t.objectProperty(
t.identifier('$theme'),
t.identifier('$theme'),
false,
true,
),
]),
];
}
result = generate(path.node).code;
},
});
const keys = activeValues.map(([key, val]: [string, any]) =>
t.objectProperty(
t.identifier(key),
t.objectExpression([
t.objectProperty(t.identifier('style'), template.expression(val.style)({}) as any),
])
)
);
visitObjectProperty(node) {
return loc(
t.objectProperty(
this.visitExpr(node.key),
this.visitExpr(node.value),
node.computed
),
node
);
}
type: 'local',
path: `${pageDependencyPrefix}${fileName}${pageComponentSuffix}`,
}
return t.objectExpression([
t.objectProperty(t.identifier('name'), t.stringLiteral(pageKey)),
t.objectProperty(t.identifier('path'), t.stringLiteral(navLink)),
t.objectProperty(t.identifier('component'), t.identifier(componentName)),
])
})
const exportStatement = t.exportDefaultDeclaration(
t.newExpression(t.identifier('Router'), [
t.objectExpression([
t.objectProperty(t.identifier('mode'), t.stringLiteral('history')),
t.objectProperty(t.identifier('routes'), t.arrayExpression(routesAST)),
]),
])
)
chunks.push({
name: codeChunkName,
linkAfter: [importChunkName],
type: ChunkType.AST,
fileType: FileType.JS,
content: [routerDeclaration, metaDeclaration, exportStatement],
})
return structure
}
if (value.extra && value.extra.raw) {
delete value.extra.raw;
}
}
if (t.isJSXNamespacedName(node.name)) {
node.name = t.stringLiteral(
node.name.namespace.name + ':' + node.name.name.name,
);
} else if (esutils.keyword.isIdentifierNameES6(node.name.name)) {
node.name.type = 'Identifier';
} else {
node.name = t.stringLiteral(node.name.name);
}
return t.inherits(t.objectProperty(node.name, value), node);
}
}
if (observerItem) {
let objProp;
//observer换成watch
let op_value = null;
if (typeItem.node.value.name == "Array" || typeItem.node.value.name == "Object") {
//Array和Object换成深度监听
if (t.isObjectProperty(observerItem.node)) {
op_value = observerItem.node.value;
} else if (t.isObjectMethod(observerItem.node)) {
op_value = t.functionExpression(null, observerItem.node.params, observerItem.node.body);
} else {
op_value = observerItem.node.value;
}
let objExp_handle = t.objectProperty(t.identifier("handler"), op_value);
let objExp_deep = t.objectProperty(t.identifier("deep"), t.booleanLiteral(true));
let properties = [objExp_handle, objExp_deep];
let objExp = t.objectExpression(properties);
//如果observer的属性名是字符串,那就进行命名的修正
if (t.isStringLiteral(objExp)) objExp.value = utils.getPropsAlias(objExp.value);
objProp = t.objectProperty(t.identifier(propItemName), objExp);
} else {
if (t.isObjectProperty(observerItem.node)) {
op_value = observerItem.node.value;
} else if (t.isObjectMethod(observerItem.node)) {
op_value = t.functionExpression(null, observerItem.node.params, observerItem.node.body);
} else {
op_value = observerItem.node.value;
}
//如果observer的属性名是字符串,那就进行命名的修正
if (t.isStringLiteral(op_value)) op_value.value = utils.getPropsAlias(op_value.value);
codeGen.memorizedIds.map(id => t.objectProperty(id, id, false, true))
);