本文整理匯總了TypeScript中@simple-dom/serializer.serialize函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript serialize函數的具體用法?TypeScript serialize怎麽用?TypeScript serialize使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了serialize函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
QUnit.test('serializes element with attribute number value correctly', (assert) => {
const { element } = helper;
const actual = serializer.serialize(element('div', {
height: 500,
}));
assert.equal(actual, '<div height="500"></div>');
});
示例2: element
QUnit.test('does not serialize siblings of an element', (assert) => {
const { element } = helper;
const htmlEl = element('html');
const head = element('head');
const body = element('body');
head.appendChild(element('meta', { content: 'foo' }));
head.appendChild(element('meta', { content: 'bar' }));
htmlEl.appendChild(head);
htmlEl.appendChild(body);
let actual = serializer.serialize(head);
assert.equal(actual, '<head><meta content="foo"><meta content="bar"></head>');
actual = serializer.serialize(body);
assert.equal(actual, '<body></body>');
});