本文整理汇总了TypeScript中parse5.Serializer类的典型用法代码示例。如果您正苦于以下问题:TypeScript Serializer类的具体用法?TypeScript Serializer怎么用?TypeScript Serializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Serializer类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: clone
clone(node) {
// e.g. document fragment
if (node.type === 'root') {
var serialized = serializer.serialize(node);
var newParser = new parse5.Parser(parse5.TreeAdapters.htmlparser2);
return newParser.parseFragment(serialized);
} else {
var temp = treeAdapter.createElement("template", null, []);
treeAdapter.appendChild(temp, node);
var serialized = serializer.serialize(temp);
var newParser = new parse5.Parser(parse5.TreeAdapters.htmlparser2);
return newParser.parseFragment(serialized).childNodes[0];
}
}
示例2: serializeDocument
export function serializeDocument(document: Object, pretty?: boolean): string {
const doc = serializer.serialize(document);
if (pretty) {
const beautify: any = require('js-beautify');
return beautify.html(doc, {indent_size: 2});
}
return doc;
}
示例3: getOuterHTML
getOuterHTML(el) {
serializer.html = '';
serializer._serializeElement(el);
return serializer.html;
}
示例4: getInnerHTML
getInnerHTML(el) { return serializer.serialize(this.templateAwareRoot(el)); }
示例5: serializeDocument
export function serializeDocument(document: Object): string {
return serializer.serialize(document);
}