Last active
September 29, 2017 09:30
-
-
Save joona/c6e6f31f40363adbdeee43393ed76f35 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can do
global.SVGElement
now..