This project is archived. Its data is read-only.

DOM API

A DOM API should be introduced that acts similar to Nokogiri (in certain ways). The DOM API should be built on top of the AST returned by Oga::Parser. It should allow the querying of elements using XPath and CSS. The latter would be built on top of XPath.

Rough sketch of the DOM API:

document = Oga::DOM::HTML.new('<p class="foo">Hello</p>')

document.css('p.foo').length # => 1
document.xpath('//p[@class="foo"]').length # => 1

TODO list:

  • XPath handling: https://github.com/YorickPeterse/oga/issues/10
  • CSS selector handling: https://github.com/YorickPeterse/oga/issues/11
  • DOM API (shocking)
    • Proper API for modifying the tree (unlike the crap Nokogiri offers), in particular adding new nodes has to work nicely
    • Better system for storing next, previous parent and child nodes. Instead of storing nodes directly in to each other a node should only contain its current index in its containing node set. Using this index we can quickly figure out surrounding nodes without having to keep 1238719381 references around.
    • Methods for querying the tree using XPath/CSS selectors.
    • Pass the root document to each node (required for absolute XPath expressions)
Assignee Loading
Time tracking Loading