Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let [, $1] = /bind(?::)?([\w]*)/g.exec(attr);
if (!!~this.supportEvents.indexOf($1)) {
eventMap += `|${$1}:${attributes[attr]}`;
element.attribs[`bind${$1}`] = `$$e2e_${$1}`;
}
});
eventMap = eventMap.replace(/^\|/, '');
element.attribs['data-_wxaTestEventMap'] = eventMap;
// generate unique id for tag.
// pagePath + hash(parentNode + prevNode) + optional(class/id)
let pagePath = path.relative(this.scheduler.wxaConfigs.context, path.dirname(this.mdl.src) + path.sep + path.basename(this.mdl.src, path.extname(this.mdl.src)));
let ele = this.getParentAndPrevNode(element);
let eleString = new Coder().decodeTemplate(domSerializer(ele, {xmlMode: true}));
let hash= getHashWithString(eleString);
let {isIeration, indexVariable} = this.findSelfOrAncestorIterationDirective(element);
let keyElement = [pagePath, hash, element.attribs.id];
if (isIeration) keyElement.push(`-{{${indexVariable}}}`);
let id = this.assembleUniqueId(keyElement);
element.attribs['data-_wxaTestUniqueId'] = id;
element.attribs['class'] = this.dropSpace((element.attribs['class'] || '') + ' '+ id);
}
}
parse(xml) {
xml.forEach((element)=>this.walkXML(element));
this.mdl.code = new Coder().decodeTemplate(domSerializer(xml, {xmlMode: true}));
}
data = data || {};
const root = data.root || {};
const selectors = data.selectors || {};
assign(svg.attribs, root);
Object.keys(selectors).forEach(selector => {
const attribs = selectors[selector];
const elements = selectAll(selector, svg);
elements.forEach(element => {
assign(element.attribs, attribs);
});
});
return serialize(dom);
}
$._serialize = function(el) {
var opts = el.options || (el.root && el.root.options)
return serialize(el, opts)
}
}
export default function render(code, ...processors) {
const dom = parseDOM(code, { xmlMode: true });
processors.forEach(processor => processor(dom));
return serialize(dom);
}
parse(mdl) {
if (mdl.xml == null) return null;
let libs = [];
mdl.xml.forEach((element) => {
libs = libs.concat(this.walkXML(element, mdl));
});
mdl.code = new Coder().decodeTemplate(domSerializer(mdl.xml, {xmlMode: true}));
return libs;
}