Skip to content

Instantly share code, notes, and snippets.

@cowboyd
Created June 3, 2010 17:25
Show Gist options
  • Save cowboyd/424183 to your computer and use it in GitHub Desktop.
Save cowboyd/424183 to your computer and use it in GitHub Desktop.
require 'v8'
cxt = V8::Context.new
cxt.load('env.js')
cxt['document'].tap do |document|
puts document
document.createElement('div').tap do |div|
puts div
div.setAttribute("id", "foo")
puts div.getAttribute("id")
document.documentElement.appendChild(div)
puts document.childNodes.length
puts document.childNodes[0]
end
end
[object HTMLDocument]
[object HTMLDivElement]
foo
1
[object HTMLHtmlElement]
Program exited with code #0 after 0.22 seconds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment