envjs 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ === 0.3.6 / 2010-05-31
2
+
3
+ * don't be sensitive to method case
4
+ * use different syntax for method lookup to work around Johnson wierdness
5
+ * fix sloppy syntax and handle formless form inputs
6
+
1
7
  === 0.3.5 / 2010-05-19
2
8
 
3
9
  * dont remove the gemspec so it can be used via gh (though not commited ... ?)
@@ -26,29 +26,29 @@ and then installing the envjs gem with
26
26
 
27
27
  The envjs gem provides the envjsrb command, which functions as an extended version of the Johnson javascript shell. For example:
28
28
 
29
- mbp:env-js smparkes$ envjsrb
30
- js> this
31
- => [object Window 0]
32
- js> window.location
33
- => about:blank
34
- js> document.innerHTML
35
- => "<html><head><title></title></head><body></body></html>"
36
- js>
29
+ mbp:env-js smparkes$ envjsrb
30
+ js> this
31
+ => [object Window 0]
32
+ js> window.location
33
+ => about:blank
34
+ js> document.innerHTML
35
+ => "<html><head><title></title></head><body></body></html>"
36
+ js>
37
37
 
38
38
  == Embedding envjs
39
39
 
40
40
  It's also possible to embed the envjs interpreter similar to the way it's done in Johnson, e.g.,
41
41
 
42
- require 'rubygems' # if necessary
43
- require 'johnson/tracemonkey'
44
- require 'envjs/runtime'
42
+ require 'rubygems' # if necessary
43
+ require 'johnson/tracemonkey'
44
+ require 'envjs/runtime'
45
45
 
46
- envjs = Johnson::Runtime.new
47
- envjs.extend Envjs::Runtime
48
- window = envjs.evaluate("window")
49
- puts window.location.to_s # == "about:blank"
50
- puts window.document.innerHTML # == "<html><head><title></title></head><body></body></html>"
51
- envjs.wait
46
+ envjs = Johnson::Runtime.new
47
+ envjs.extend Envjs::Runtime
48
+ window = envjs.evaluate("window")
49
+ puts window.location.to_s # == "about:blank"
50
+ puts window.document.innerHTML # == "<html><head><title></title></head><body></body></html>"
51
+ envjs.wait
52
52
 
53
53
  You need the Runtime#wait at the end to give env.js's event loop a chance to execute queued events and timers. You may need to do this at other times as well, depending on the asynchronous nature of your application.
54
54
 
@@ -1,6 +1,6 @@
1
1
  module Envjs
2
2
 
3
- VERSION = "0.3.5"
3
+ VERSION = "0.3.6"
4
4
 
5
5
  def self.js_exception_stack e
6
6
  result = %(Exception: )+e.to_s
@@ -2163,8 +2163,6 @@ $w.removeEventListener = function(type, fn){
2163
2163
  __removeEventListener__(this, type, fn)
2164
2164
  };
2165
2165
 
2166
-
2167
-
2168
2166
  function __dispatchEvent__(target, event, bubbles){
2169
2167
  try{
2170
2168
  $debug("dispatching event " + event.type);
@@ -2289,7 +2287,7 @@ function __dispatchEvent__(target, event, bubbles){
2289
2287
  }
2290
2288
  data = $master["static"].__formSerialize__(target,undefined,boundary);
2291
2289
  var options = {method: target.method || "get", referer: this.location.href};
2292
- if (options.method === "post" || options.method === "put") {
2290
+ if (options.method.toLowerCase() === "post" || options.method.toLowerCase() === "put") {
2293
2291
  options.data = data;
2294
2292
  var undef;
2295
2293
  data = undef;
@@ -274,7 +274,7 @@ EOJS
274
274
 
275
275
  inner.load = lambda { |*files|
276
276
  files.each do |f|
277
- master.load.call f, inner
277
+ master['load'].call f, inner
278
278
  end
279
279
  }
280
280
 
@@ -322,7 +322,7 @@ EOJS
322
322
  outer[k] = v
323
323
  end
324
324
 
325
- master.load.call Envjs::EVENT_LOOP, global
325
+ master['load'].call Envjs::EVENT_LOOP, global
326
326
 
327
327
  static = new_global
328
328
 
@@ -334,10 +334,10 @@ EOJS
334
334
 
335
335
  # fake it ...
336
336
  static["isInner"] = true
337
- master.load.call Envjs::STATIC, static
337
+ master['load'].call Envjs::STATIC, static
338
338
  master["static"] = static
339
339
 
340
- master.load.call Envjs::ENVJS, inner
340
+ master['load'].call Envjs::ENVJS, inner
341
341
 
342
342
  inner = nil
343
343
  end
@@ -5002,7 +5002,7 @@ var inputElements_status = {};
5002
5002
 
5003
5003
  var inputElements_onchange = {
5004
5004
  onchange: function(event){
5005
- return __eval__(this.getAttribute('onchange')||'', this)
5005
+ return __eval__(this.getAttribute('onchange')||'', this);
5006
5006
  }
5007
5007
  };
5008
5008
 
@@ -5124,7 +5124,7 @@ __extend__(HTMLTypeValueInputs.prototype, {
5124
5124
  }
5125
5125
  parent = parent.parentNode;
5126
5126
  }
5127
- if(parent.tagName == "FORM") {
5127
+ if(parent && parent.tagName == "FORM") {
5128
5128
  var xpath = './/input[@type="radio" and @name="'+this.name+'"]';
5129
5129
  var nodes =
5130
5130
  this.ownerDocument.evaluate(xpath,parent, null, XPathResult.ANY_TYPE,null );
@@ -126,7 +126,7 @@ var inputElements_status = {};
126
126
 
127
127
  var inputElements_onchange = {
128
128
  onchange: function(event){
129
- return __eval__(this.getAttribute('onchange')||'', this)
129
+ return __eval__(this.getAttribute('onchange')||'', this);
130
130
  }
131
131
  };
132
132
 
@@ -248,7 +248,7 @@ __extend__(HTMLTypeValueInputs.prototype, {
248
248
  }
249
249
  parent = parent.parentNode;
250
250
  }
251
- if(parent.tagName == "FORM") {
251
+ if(parent && parent.tagName == "FORM") {
252
252
  var xpath = './/input[@type="radio" and @name="'+this.name+'"]';
253
253
  var nodes =
254
254
  this.ownerDocument.evaluate(xpath,parent, null, XPathResult.ANY_TYPE,null );
@@ -47,8 +47,6 @@ $w.removeEventListener = function(type, fn){
47
47
  __removeEventListener__(this, type, fn)
48
48
  };
49
49
 
50
-
51
-
52
50
  function __dispatchEvent__(target, event, bubbles){
53
51
  try{
54
52
  $debug("dispatching event " + event.type);
@@ -173,7 +171,7 @@ function __dispatchEvent__(target, event, bubbles){
173
171
  }
174
172
  data = $master["static"].__formSerialize__(target,undefined,boundary);
175
173
  var options = {method: target.method || "get", referer: this.location.href};
176
- if (options.method === "post" || options.method === "put") {
174
+ if (options.method.toLowerCase() === "post" || options.method.toLowerCase() === "put") {
177
175
  options.data = data;
178
176
  var undef;
179
177
  data = undef;
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 5
9
- version: 0.3.5
8
+ - 6
9
+ version: 0.3.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Resig
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-05-19 00:00:00 -07:00
19
+ date: 2010-05-31 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency