Skip to content

Instantly share code, notes, and snippets.

@twolfson
Created November 19, 2012 09:00
Show Gist options
  • Save twolfson/4109686 to your computer and use it in GitHub Desktop.
Save twolfson/4109686 to your computer and use it in GitHub Desktop.
Thoughts on non-innerHTML HTML to DOM interpretter

I am probably never going to get to this so I am documenting my thoughts publicly.

Methods to try

  • Stack parse
    • Consult the stack methodology that json2.js uses (should be on Google Code)
  • Resig (HTML2XML) + jQuery (XMLInterpretter)

Make a spec

  • Deep equal HTML to DOM tree/attributes and nodeType
    • Get as close to DOM specification as possible within unit tests
    • Another unit test, make a div, parse it via our interpretter and compare it to its innerHTML

Options

  • Throw away comments and end tags
  • Throw away text nodes (optimization for size + attribution inspection only)
  • Emit events (e.g. 'setAttr') during parsing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment