mynyml/harmony

can't load prototype.js

Closed this issue · 2 comments

code:

require 'rubygems'
require 'harmony'
h = Harmony::Page.new
h.load 'http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js'

exceptions:
/usr/lib/ruby/gems/1.8/gems/envjs-0.2.0/lib/envjs/static.js:20097 [JavaScript]: alert is not defined (Johnson::Error)
from /usr/lib/ruby/gems/1.8/gems/envjs-0.2.0/lib/envjs/static.js:20043 [JavaScript]
from /usr/lib/ruby/gems/1.8/gems/envjs-0.2.0/lib/envjs/static.js:20552 [JavaScript]
from /usr/lib/ruby/gems/1.8/gems/envjs-0.2.0/lib/envjs/static.js:20522 [JavaScript]
from /usr/lib/ruby/gems/1.8/gems/envjs-0.2.0/lib/envjs/static.js:20487 [JavaScript]
from /usr/lib/ruby/gems/1.8/gems/envjs-0.2.0/lib/envjs/static.js:20019 [JavaScript]
from /usr/lib/ruby/gems/1.8/gems/envjs-0.2.0/lib/envjs/static.js:19941 [JavaScript]
from /usr/lib/ruby/gems/1.8/gems/envjs-0.2.0/lib/envjs/static.js:19772:in xPathStep' [JavaScript] from /usr/lib/ruby/gems/1.8/gems/envjs-0.2.0/lib/envjs/static.js:19777:inxPathStep' [JavaScript]
from /usr/lib/ruby/gems/1.8/gems/envjs-0.2.0/lib/envjs/static.js:19777:in xPathStep' [JavaScript] from /usr/lib/ruby/gems/1.8/gems/envjs-0.2.0/lib/envjs/static.js:19728 [JavaScript] from /usr/lib/ruby/gems/1.8/gems/envjs-0.2.0/lib/envjs/static.js:18912 [JavaScript] from /usr/lib/ruby/gems/1.8/gems/envjs-0.2.0/lib/envjs/static.js:3926 [JavaScript] from http:/ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js:3187 [JavaScript] from http:/ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js:3177 [JavaScript] from http:/ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js:3175 [JavaScript] from /usr/lib/ruby/gems/1.8/gems/johnson-2.0.0.pre3/lib/johnson/tracemonkey/runtime.rb:49:inevaluate_compiled_script'
from /usr/lib/ruby/gems/1.8/gems/envjs-0.2.0/lib/envjs/runtime.rb:54:in evaluate' from /usr/lib/ruby/gems/1.8/gems/envjs-0.2.0/lib/envjs/runtime.rb:267:inextended'
from /usr/lib/ruby/gems/1.8/gems/johnson-2.0.0.pre3/lib/johnson/tracemonkey/js_land_proxy.rb:16:in call' from /usr/lib/ruby/gems/1.8/gems/johnson-2.0.0.pre3/lib/johnson/tracemonkey/js_land_proxy.rb:16:insend'
from /usr/lib/ruby/gems/1.8/gems/johnson-2.0.0.pre3/lib/johnson/tracemonkey/js_land_proxy.rb:16:in send_with_possible_block' from /usr/lib/ruby/gems/1.8/gems/johnson-2.0.0.pre3/lib/johnson/ruby_land_proxy.rb:110:incall_function_property'
from /usr/lib/ruby/gems/1.8/gems/envjs-0.2.0/lib/envjs/env.js:105 [JavaScript]
from /usr/lib/ruby/gems/1.8/gems/johnson-2.0.0.pre3/lib/johnson/ruby_land_proxy.rb:110:in method_missing' from /usr/lib/ruby/gems/1.8/gems/harmony-0.5.4/lib/harmony/page.rb:76:inload'
from /usr/lib/ruby/gems/1.8/gems/harmony-0.5.4/lib/harmony/page.rb:75:in each' from /usr/lib/ruby/gems/1.8/gems/harmony-0.5.4/lib/harmony/page.rb:75:inload'
from a.rb:4

looks like this specific version of prototype calls the xpath function local-name()

var xpath = ".//*[local-name()='ul' or local-name()='UL']" +
"//*[local-name()='li' or local-name()='LI']";

which is simply unimplemented upstream in env.js

'local-name': function(ctx) {
  alert('not implmented yet: XPath function local-name()');
},

I tried to reproduce in different prototype lib versions:

v1.6.1.0 - (latest stable version) causes this error
v1.6.0.3 - runs fine
HEAD from the github repo - runs fine

So until this is fixed upstream you could use v1.6.0.3 or HEAD if this works in your project (instructions to build HEAD can be found in prototype's README, http://github.com/sstephenson/prototype)

Thanks for the report.

Thanks for the reply, It works fine for me also with v1.6.0.3 and scriptaculous 1.8.2.