本文整理匯總了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);
}