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