mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-02 06:29:40 +08:00
Change all document.body! to document.body (#27920)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import Bricks from 'bricks.js';
|
||||
|
||||
const bricks = Bricks({
|
||||
container: document.body!.firstChild!,
|
||||
container: document.body.firstChild!,
|
||||
packed: 'packed',
|
||||
sizes: [
|
||||
{ columns: 2, gutter: 10 },
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
clipboard.copy("Hello World");
|
||||
clipboard.copy(document.body!).then(() => console.log("success"));
|
||||
clipboard.copy(document.body).then(() => console.log("success"));
|
||||
|
||||
clipboard.paste().then(val => console.log(val));
|
||||
|
||||
@@ -47,12 +47,12 @@ undef = dispatch.on('unknown') as undefined;
|
||||
dispatch.on('bar', dispatch.on('bar')!);
|
||||
|
||||
dispatch.call('foo');
|
||||
dispatch.call('foo', document.body!);
|
||||
dispatch.call('foo', document.body!, { a: 3, b: 'test' }, 1);
|
||||
dispatch.call('foo', document.body);
|
||||
dispatch.call('foo', document.body, { a: 3, b: 'test' }, 1);
|
||||
|
||||
dispatch.apply('bar');
|
||||
dispatch.apply('bar', document.body!);
|
||||
dispatch.apply('bar', document.body!, [{ a: 3, b: 'test' }, 1]);
|
||||
dispatch.apply('bar', document.body);
|
||||
dispatch.apply('bar', document.body, [{ a: 3, b: 'test' }, 1]);
|
||||
|
||||
dispatch.on('bar', null);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
let render = createApp(document.body!)
|
||||
let render = createApp(document.body)
|
||||
|
||||
function main(state: any){
|
||||
let vnode = view(state, (action: any) => main({ count: 0 }))
|
||||
@@ -43,7 +43,7 @@
|
||||
return element('div', { class: `size-${ props.size }` })
|
||||
}
|
||||
|
||||
const render = createApp(document.body!)
|
||||
const render = createApp(document.body)
|
||||
|
||||
render(element(App, { size: 'small' }))
|
||||
|
||||
@@ -82,11 +82,11 @@
|
||||
(function (){
|
||||
const { createApp, element } = deku
|
||||
|
||||
let render: Function = createApp(document.body!)
|
||||
let render: Function = createApp(document.body)
|
||||
|
||||
render(element('div'))
|
||||
|
||||
render = createApp(document.body!, (action: any) => {
|
||||
render = createApp(document.body, (action: any) => {
|
||||
render(element('div'))
|
||||
})
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
let $container: JQueryNotifyWidget = $("<div style='display:none' class='noprint'><div></div></div>").appendTo(document.body!).notify();
|
||||
let $container: JQueryNotifyWidget = $("<div style='display:none' class='noprint'><div></div></div>").appendTo(document.body).notify();
|
||||
|
||||
let notification: JQueryNotifyInstance = $container.notify(
|
||||
"create",
|
||||
|
||||
@@ -17,7 +17,7 @@ function test_executing_scripts1() {
|
||||
</body>`);
|
||||
|
||||
// The script will not be executed, by default:
|
||||
dom.window.document.body!.children.length === 1;
|
||||
dom.window.document.body.children.length === 1;
|
||||
}
|
||||
|
||||
function test_executing_scripts2() {
|
||||
@@ -26,14 +26,14 @@ function test_executing_scripts2() {
|
||||
</body>`, { runScripts: 'dangerously' });
|
||||
|
||||
// The script will be executed and modify the DOM:
|
||||
dom.window.document.body!.children.length === 2;
|
||||
dom.window.document.body.children.length === 2;
|
||||
}
|
||||
|
||||
function test_executing_scripts3() {
|
||||
const window = (new JSDOM(``, { runScripts: 'outside-only' })).window;
|
||||
|
||||
window.eval(`document.body.innerHTML = "<p>Hello, world!</p>";`);
|
||||
window.document.body!.children.length === 1;
|
||||
window.document.body.children.length === 1;
|
||||
}
|
||||
|
||||
function test_virtualConsole() {
|
||||
@@ -86,7 +86,7 @@ function test_nodeLocation() {
|
||||
);
|
||||
|
||||
const document = dom.window.document;
|
||||
const bodyEl = document.body!; // implicitly created
|
||||
const bodyEl = document.body; // implicitly created
|
||||
const pEl = document.querySelector('p')!;
|
||||
const textNode = pEl.firstChild!;
|
||||
const imgEl = document.querySelector('img')!;
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as Mark from 'mark.js';
|
||||
/* test instance */
|
||||
const mark = new Mark(document.querySelectorAll('div'));
|
||||
const markBySelector = new Mark('div');
|
||||
const markByElement = new Mark(document.body!);
|
||||
const markByElement = new Mark(document.body);
|
||||
|
||||
mark.mark('keyword');
|
||||
mark.mark('keyword', {
|
||||
|
||||
@@ -18,7 +18,7 @@ const template: Template = require('template.marko');
|
||||
// $ExpectType RenderResult
|
||||
template
|
||||
.renderSync({ name: 'Marko' })
|
||||
.appendTo(document.body!);
|
||||
.appendTo(document.body);
|
||||
|
||||
createServer((req, res) => {
|
||||
res.setHeader('content-type', 'text/html');
|
||||
@@ -30,12 +30,12 @@ const template: Template = require('template.marko');
|
||||
.render({ $global: { flags: ['mobile'] } })
|
||||
.then((result) => {
|
||||
// $ExpectType RenderResult
|
||||
result.appendTo(document.body!);
|
||||
result.appendTo(document.body);
|
||||
});
|
||||
|
||||
template.render({}, (err: Error | null, result: RenderResult) => {
|
||||
// $ExpectType RenderResult
|
||||
result.appendTo(document.body!);
|
||||
result.appendTo(document.body);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ const FRAME_BUDGET = 100;
|
||||
});
|
||||
};
|
||||
|
||||
m.render(document.body!, userInputs(users));
|
||||
m.render(document.body, userInputs(users));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -246,7 +246,7 @@ const FRAME_BUDGET = 100;
|
||||
};
|
||||
|
||||
// example 1
|
||||
m.route(document.body!, "/", {
|
||||
m.route(document.body, "/", {
|
||||
"/": {
|
||||
view() {
|
||||
return m(Layout, m(Home));
|
||||
@@ -260,7 +260,7 @@ const FRAME_BUDGET = 100;
|
||||
});
|
||||
|
||||
// example 2
|
||||
m.route(document.body!, "/", {
|
||||
m.route(document.body, "/", {
|
||||
"/": {
|
||||
render() {
|
||||
return m(Layout, m(Home));
|
||||
@@ -285,7 +285,7 @@ const FRAME_BUDGET = 100;
|
||||
},
|
||||
};
|
||||
|
||||
m.route(document.body!, "/", {
|
||||
m.route(document.body, "/", {
|
||||
"/": {
|
||||
render() {
|
||||
return m(Anon1);
|
||||
@@ -313,7 +313,7 @@ const FRAME_BUDGET = 100;
|
||||
}
|
||||
};
|
||||
|
||||
m.route(document.body!, "/user/list", {
|
||||
m.route(document.body, "/user/list", {
|
||||
"/user/list": {
|
||||
onmatch: state.loadUsers,
|
||||
render() {
|
||||
@@ -330,7 +330,7 @@ const FRAME_BUDGET = 100;
|
||||
{
|
||||
let progress = 0;
|
||||
|
||||
m.mount(document.body!, {
|
||||
m.mount(document.body, {
|
||||
view() {
|
||||
return [
|
||||
m("input[type=file]", { onchange: upload }),
|
||||
@@ -396,7 +396,7 @@ const FRAME_BUDGET = 100;
|
||||
deserialize: value => value
|
||||
})
|
||||
.then(svg => {
|
||||
m.render(document.body!, m.trust(svg));
|
||||
m.render(document.body, m.trust(svg));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ class Comp4 implements ClassComponent<Comp4Attrs> {
|
||||
//
|
||||
// Test that all are mountable components
|
||||
//
|
||||
m.route(document.body!, '/', {
|
||||
m.route(document.body, '/', {
|
||||
'/comp0': Comp0,
|
||||
'/comp1': Comp1,
|
||||
'/comp2': Comp2,
|
||||
|
||||
@@ -148,7 +148,7 @@ function comp5(): Component<Comp4Attrs, Comp5State> {
|
||||
//
|
||||
// Test that all are mountable components
|
||||
//
|
||||
m.route(document.body!, '/', {
|
||||
m.route(document.body, '/', {
|
||||
'/comp0': comp0,
|
||||
'/comp1': comp1,
|
||||
'/comp2': comp2,
|
||||
|
||||
@@ -10,9 +10,9 @@ const params = parseQueryString('?id=123');
|
||||
|
||||
const qstr = buildQueryString({id: 123});
|
||||
|
||||
render(document.body!, 'Hello');
|
||||
render(document.body!, h('h1', 'Test'));
|
||||
render(document.body!, [
|
||||
render(document.body, 'Hello');
|
||||
render(document.body, h('h1', 'Test'));
|
||||
render(document.body, [
|
||||
h('h1', 'Test'), "abc", null, 123, false, h('p', 'Vnode array'),
|
||||
['a', 123, undefined, h('div', 'Nested')]
|
||||
]);
|
||||
|
||||
@@ -66,7 +66,7 @@ const routeResolver: RouteResolver<Attrs, RRState> & RRState = {
|
||||
}
|
||||
};
|
||||
|
||||
route(document.body!, '/', {
|
||||
route(document.body, '/', {
|
||||
'/': component1,
|
||||
'/test1': {
|
||||
onmatch(args, path) {
|
||||
|
||||
@@ -16,7 +16,7 @@ const XFoo = document.registerElement("x-foo", {
|
||||
|
||||
const xFoo = new XFoo();
|
||||
xFoo.textContent = "";
|
||||
document.body!.appendChild(xFoo);
|
||||
document.body.appendChild(xFoo);
|
||||
|
||||
window.CustomElements.hasNative;
|
||||
window.CustomElements.flags;
|
||||
|
||||
@@ -31,7 +31,7 @@ client.add(magnetURI, {}, torrent => {
|
||||
a.href = url;
|
||||
}
|
||||
a.textContent = 'Download ' + file.name;
|
||||
document.body!.appendChild(a);
|
||||
document.body.appendChild(a);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user