本文整理汇总了TypeScript中typed-dom.html函数的典型用法代码示例。如果您正苦于以下问题:TypeScript html函数的具体用法?TypeScript html怎么用?TypeScript html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了html函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('cancel', done => {
let cnt = 0;
const cancellation = new Cancellation<Error>();
script(
{
src: parse(html('head', [html('script', { class: 'test' })]).outerHTML).extract(),
dst: parse('').extract()
},
new Set([]),
{
ignore: '',
reload: '',
logger: 'head'
},
1e3,
cancellation,
{
fetch: async script => {
assert(cnt === 0 && ++cnt);
assert(script.className === 'test');
return Right(tuple([script, '']));
},
evaluate: script => {
assert(++cnt === NaN);
return Left(AtomicPromise.resolve(Right(script)));
},
})
.then(m => {
assert(cnt === 1 && ++cnt);
assert(m.extract(e => e) instanceof Error);
done();
});
cancellation.cancel(new Error());
});
示例2: it
it('submit get', () => {
const req = new RouterEventRequest(html('form', { method: 'GET', action: './search' }, [
html('input', { name: 'test', type: 'text', value: 'abc' })
]));
assert(req.url.reference === standardize('./search?test=abc'));
assert(req.method === RouterEventMethod.GET);
assert(req.body === null);
});
示例3: it
it('', () => {
const el = html('noscript', [html('hr')]);
document.body.appendChild(el);
const texts = fixNoscript(el.ownerDocument!)
.map(([, {textContent}]) => textContent);
assert.deepStrictEqual(texts, ['<hr>']);
el.remove();
});
示例4: it
it('empty', () => {
const documents = {
src: parse(html('head', [
]).outerHTML).extract(),
dst: parse(html('head', [
]).outerHTML).extract(),
};
sync(pair(find(documents.src, 'meta'), find(documents.dst, 'meta'), (a, b) => a.id === b.id), documents.dst.head!);
assert.deepStrictEqual(find(documents.dst, 'meta').map(el => el.id), [
]);
});
示例5: it
it('submit external', function (done) {
const url = '//external';
const form = html('form', { action: url }, [
html('input', { type: 'submit', value: 'submit' }),
]);
document.body.appendChild(form);
once(document, 'form', 'submit', ev => {
assert(!validate(new URL(standardize(url)), new Config({}), new RouterEvent(ev)));
ev.preventDefault();
form.remove();
done();
});
form.querySelector('input')!.click();
});