Skip to content

Instantly share code, notes, and snippets.

@joona
Last active September 29, 2017 09:30
Show Gist options
  • Save joona/c6e6f31f40363adbdeee43393ed76f35 to your computer and use it in GitHub Desktop.
Save joona/c6e6f31f40363adbdeee43393ed76f35 to your computer and use it in GitHub Desktop.
<html><head><style></style></head><body><header><nav>NO:DOM</nav></header><div class="container"><h1>Hello world!!!</h1></div></body></html>
<html><head><style></style></head><body><header><nav>NO:DOM</nav></header><div class="container"><h1>Hello world!!!</h1></div></body></html>
<html><head><style></style><style></style></head><body><header><nav>NO:DOMNO:DOM</nav><nav>NO:DOMNO:DOM</nav></header><div class="container"><h1>Hello world!!!Hello world!!!</h1><h1>Hello world!!!Hello world!!!</h1></div><header><nav>NO:DOMNO:DOM</nav><nav>NO:DOMNO:DOM</nav></header><div class="container"><h1>Hello world!!!Hello world!!!</h1><h1>Hello world!!!Hello world!!!</h1></div></body></html>
<html><head><style></style><style></style></head><body><header><nav>NO:DOMNO:DOM</nav><nav>NO:DOMNO:DOM</nav></header><div class="container"><h1>Hello world!!!Hello world!!!</h1><h1>Hello world!!!Hello world!!!</h1></div><header><nav>NO:DOMNO:DOM</nav><nav>NO:DOMNO:DOM</nav></header><div class="container"><h1>Hello world!!!Hello world!!!</h1><h1>Hello world!!!Hello world!!!</h1></div></body></html>
const { Document } = require('nodom');
const document = new Document();
const window = {
SVGElement: function() {}
};
global.document = document;
global.window = window;
const redom = require('redom');
const { el, text, mount } = redom;
const stylesheet = (src) => {
return el('style', {
type: 'text/css',
src
});
}
class Container {
constructor() {
this.el = el('div.container');
}
}
class Navigation {
constructor() {
this.el = el('header', [
this.nav = el('nav', [
text('NO:DOM')
])
])
}
}
const templates = {
test() {
mount(document.head, stylesheet('/app.less'));
mount(document.body, new Navigation());
const container = new Container();
mount(container, el('h1', text('Hello world!!!')));
mount(document.body, container);
console.log(document.documentElement.outerHTML);
return document.documentElement.outerHTML;
}
}
if(!module.parent) {
console.log(templates.test());
console.log(templates.test());
}
@pakastin
Copy link

You can do global.SVGElement now..

@pakastin
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment