from htmltree import *
def start():
    console.log("Starting")
    newcontent = H1("Sanity check PASS", _class='test', style=dict(color='green'))
    console.log(newcontent.render(0))
    document.body.innerHTML = newcontent.render()
    console.log("Finished")
document.addEventListener('DOMContentLoaded', start)


from htmltree import *
def start():
    console.log("Starting")
    ## insert a style element at the end of the <head?
    cssrules = {'.test':{'color':'green', 'text-align':'center'}}
    style = Style(**cssrules)
    document.head.insertAdjacentHTML('beforeend', style.render())

    ## Replace the <body> content
    newcontent = Div(H1("Sanity check PASS", _class='test'))
    document.body.innerHTML = newcontent.render()
    console.log("Finished")

## JS is event driven.
## Wait for DOM load to complete before firing
## our start() function.
document.addEventListener('DOMContentLoaded', start)


Fix <style> rendering under Transcrypt.
Fix <style> rendering under Transcrypt.

The hasattr test in renderCss() was failing when it shouldn't have.
Fixed by removal. Updated tests/client.py to create and append a style
element to detect problems related to Style() on the client side.

  from htmltree import *
  def start():
      console.log("Starting")
+     ## insert a style element at the end of the <head?
+     cssrules = {'.test':{'color':'green', 'text-align':'center'}}
+     style = Style(**cssrules)
+     document.head.insertAdjacentHTML('beforeend', style.render())
+ 
+     ## Replace the <body> content
-     newcontent = H1("Sanity check PASS", _class='test', style=dict(color='green'))
+     newcontent = Div(H1("Sanity check PASS", _class='test'))
-     console.log(newcontent.render(0))
      document.body.innerHTML = newcontent.render()
      console.log("Finished")
+ 
+ ## JS is event driven.
+ ## Wait for DOM load to complete before firing
+ ## our start() function.
  document.addEventListener('DOMContentLoaded', start)
  
  
Fix <style> rendering under Transcrypt.
## Code Before:
from htmltree import *
def start():
    console.log("Starting")
    newcontent = H1("Sanity check PASS", _class='test', style=dict(color='green'))
    console.log(newcontent.render(0))
    document.body.innerHTML = newcontent.render()
    console.log("Finished")
document.addEventListener('DOMContentLoaded', start)


## Instruction:
Fix <style> rendering under Transcrypt.
## Code After:
from htmltree import *
def start():
    console.log("Starting")
    ## insert a style element at the end of the <head?
    cssrules = {'.test':{'color':'green', 'text-align':'center'}}
    style = Style(**cssrules)
    document.head.insertAdjacentHTML('beforeend', style.render())

    ## Replace the <body> content
    newcontent = Div(H1("Sanity check PASS", _class='test'))
    document.body.innerHTML = newcontent.render()
    console.log("Finished")

## JS is event driven.
## Wait for DOM load to complete before firing
## our start() function.
document.addEventListener('DOMContentLoaded', start)

