envjs 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. data/.jslintrbrc +29 -0
  2. data/.project +17 -0
  3. data/CHANGELOG.rdoc +3 -0
  4. data/DTD/xhtml-lat1.ent +196 -0
  5. data/DTD/xhtml-special.ent +80 -0
  6. data/DTD/xhtml-symbol.ent +237 -0
  7. data/DTD/xhtml.soc +14 -0
  8. data/DTD/xhtml1-frameset.dtd +1235 -0
  9. data/DTD/xhtml1-strict.dtd +978 -0
  10. data/DTD/xhtml1-transitional.dtd +1201 -0
  11. data/DTD/xhtml1.dcl +192 -0
  12. data/Makefile +7 -0
  13. data/Manifest.txt +287 -0
  14. data/{README → README.rdoc} +24 -3
  15. data/Rakefile +196 -0
  16. data/Wakefile +24 -0
  17. data/build.properties +9 -0
  18. data/build.xml +247 -0
  19. data/gm/jquery.js +6002 -0
  20. data/gm/mainx.js +2648 -0
  21. data/gm/sensx.js +135 -0
  22. data/gm/t.js +6 -0
  23. data/gm/x.html +76 -0
  24. data/htmlparser/BrowserTreeBuilder.java +456 -0
  25. data/htmlparser/README +34 -0
  26. data/htmlparser/build.sh +38 -0
  27. data/jsl/jsl +0 -0
  28. data/jsl/jsl.default.conf +129 -0
  29. data/jsl/jsl.exe +0 -0
  30. data/lib/envjs.rb +2 -0
  31. data/lib/envjs/env.js +22 -3
  32. data/lib/envjs/event_loop.js +2 -0
  33. data/lib/envjs/static.js +155 -21
  34. data/licenses/GPL-LICENSE.txt +278 -0
  35. data/licenses/MIT-LICENSE.txt +20 -0
  36. data/src/base64.js +80 -0
  37. data/src/build.js +6 -0
  38. data/src/cruft/bad.html +24 -0
  39. data/src/cruft/dom.js +606 -0
  40. data/src/cruft/element.js +297 -0
  41. data/src/cruft/good.html +30 -0
  42. data/src/cruft/good.js +32 -0
  43. data/src/cruft/internal.js +81 -0
  44. data/src/cruft/parser.js +458 -0
  45. data/src/css/properties.js +293 -0
  46. data/src/css/rule.js +22 -0
  47. data/src/css/sizzle.js +717 -0
  48. data/src/css/stylesheet.js +52 -0
  49. data/src/dom/attr.js +55 -0
  50. data/src/dom/cdatasection.js +31 -0
  51. data/src/dom/characterdata.js +119 -0
  52. data/src/dom/comment.js +30 -0
  53. data/src/dom/doctype.js +9 -0
  54. data/src/dom/document.js +553 -0
  55. data/src/dom/dom.js +134 -0
  56. data/src/dom/element.js +217 -0
  57. data/src/dom/entities.js +273 -0
  58. data/src/dom/exception.js +28 -0
  59. data/src/dom/fragment.js +37 -0
  60. data/src/dom/implementation.js +602 -0
  61. data/src/dom/instruction.js +51 -0
  62. data/src/dom/namednodemap.js +374 -0
  63. data/src/dom/namespace.js +50 -0
  64. data/src/dom/node.js +618 -0
  65. data/src/dom/nodelist.js +195 -0
  66. data/src/dom/parser.js +1207 -0
  67. data/src/dom/text.js +73 -0
  68. data/src/event/event.js +39 -0
  69. data/src/event/mouseevent.js +4 -0
  70. data/src/event/uievent.js +8 -0
  71. data/src/html/a.js +110 -0
  72. data/src/html/anchor.js +80 -0
  73. data/src/html/area.js +57 -0
  74. data/src/html/base.js +26 -0
  75. data/src/html/blockquote-q.js +19 -0
  76. data/src/html/body.js +19 -0
  77. data/src/html/button.js +21 -0
  78. data/src/html/canvas.js +14 -0
  79. data/src/html/col-colgroup.js +49 -0
  80. data/src/html/collection.js +72 -0
  81. data/src/html/cookie.js +151 -0
  82. data/src/html/del-ins.js +25 -0
  83. data/src/html/div.js +28 -0
  84. data/src/html/document.js +359 -0
  85. data/src/html/element.js +380 -0
  86. data/src/html/fieldset.js +19 -0
  87. data/src/html/form.js +484 -0
  88. data/src/html/frame.js +89 -0
  89. data/src/html/frameset.js +25 -0
  90. data/src/html/head.js +44 -0
  91. data/src/html/html.js +0 -0
  92. data/src/html/htmlparser.js +340 -0
  93. data/src/html/iframe.js +26 -0
  94. data/src/html/image.js +0 -0
  95. data/src/html/img.js +62 -0
  96. data/src/html/input-elements.js +307 -0
  97. data/src/html/input.js +65 -0
  98. data/src/html/label.js +26 -0
  99. data/src/html/legend.js +19 -0
  100. data/src/html/link.js +82 -0
  101. data/src/html/map.js +22 -0
  102. data/src/html/meta.js +37 -0
  103. data/src/html/object.js +89 -0
  104. data/src/html/optgroup.js +25 -0
  105. data/src/html/option.js +97 -0
  106. data/src/html/param.js +38 -0
  107. data/src/html/script.js +122 -0
  108. data/src/html/select.js +129 -0
  109. data/src/html/style.js +31 -0
  110. data/src/html/table.js +199 -0
  111. data/src/html/tbody-thead-tfoot.js +91 -0
  112. data/src/html/td-th.js +18 -0
  113. data/src/html/textarea.js +25 -0
  114. data/src/html/title.js +20 -0
  115. data/src/html/tr.js +114 -0
  116. data/src/intro.js +141 -0
  117. data/src/outro.js +70 -0
  118. data/src/parser/html5.detailed.js +10762 -0
  119. data/src/parser/html5.min.js +503 -0
  120. data/src/parser/html5.pretty.js +10815 -0
  121. data/src/parser/intro.js +42 -0
  122. data/src/parser/outro.js +9 -0
  123. data/src/platform/core.js +323 -0
  124. data/src/platform/johnson.js +479 -0
  125. data/src/platform/rhino.js +327 -0
  126. data/src/platform/static/intro.js +41 -0
  127. data/src/platform/static/outro.js +30 -0
  128. data/src/profile/aop.js +238 -0
  129. data/src/profile/profile.js +402 -0
  130. data/src/serializer/xml.js +21 -0
  131. data/src/svg/animatedstring.js +25 -0
  132. data/src/svg/document.js +25 -0
  133. data/src/svg/element.js +22 -0
  134. data/src/svg/locatable.js +17 -0
  135. data/src/svg/rect.js +18 -0
  136. data/src/svg/rectelement.js +24 -0
  137. data/src/svg/stylable.js +49 -0
  138. data/src/svg/svgelement.js +22 -0
  139. data/src/svg/transformable.js +15 -0
  140. data/src/window/css.js +15 -0
  141. data/src/window/dialog.js +16 -0
  142. data/src/window/document.js +28 -0
  143. data/src/window/event.js +262 -0
  144. data/src/window/history.js +62 -0
  145. data/src/window/location.js +138 -0
  146. data/src/window/navigator.js +48 -0
  147. data/src/window/screen.js +53 -0
  148. data/src/window/timer.js +21 -0
  149. data/src/window/window.js +284 -0
  150. data/src/window/xhr.js +127 -0
  151. data/src/xpath/expression.js +49 -0
  152. data/src/xpath/implementation.js +2482 -0
  153. data/src/xpath/result.js +67 -0
  154. data/src/xpath/util.js +551 -0
  155. data/src/xpath/xmltoken.js +149 -0
  156. data/src/xslt/COPYING +34 -0
  157. data/src/xslt/ajaxslt-0.8.1/AUTHORS +1 -0
  158. data/src/xslt/ajaxslt-0.8.1/ChangeLog +136 -0
  159. data/src/xslt/ajaxslt-0.8.1/Makefile +49 -0
  160. data/src/xslt/ajaxslt-0.8.1/README +102 -0
  161. data/src/xslt/ajaxslt-0.8.1/TODO +15 -0
  162. data/src/xslt/ajaxslt-0.8.1/dom.js +566 -0
  163. data/src/xslt/ajaxslt-0.8.1/dom_unittest.html +24 -0
  164. data/src/xslt/ajaxslt-0.8.1/dom_unittest.js +131 -0
  165. data/src/xslt/ajaxslt-0.8.1/simplelog.js +79 -0
  166. data/src/xslt/ajaxslt-0.8.1/test/xpath.html +18 -0
  167. data/src/xslt/ajaxslt-0.8.1/test/xpath_script.js +45 -0
  168. data/src/xslt/ajaxslt-0.8.1/test/xslt.html +58 -0
  169. data/src/xslt/ajaxslt-0.8.1/test/xslt_script.js +33 -0
  170. data/src/xslt/ajaxslt-0.8.1/unittestsuite.html +26 -0
  171. data/src/xslt/ajaxslt-0.8.1/xmltoken.js +149 -0
  172. data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.html +18 -0
  173. data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.js +811 -0
  174. data/src/xslt/ajaxslt-0.8.1/xpath_unittest.html +39 -0
  175. data/src/xslt/ajaxslt-0.8.1/xpath_unittest.js +557 -0
  176. data/src/xslt/ajaxslt-0.8.1/xpathdebug.js +234 -0
  177. data/src/xslt/ajaxslt-0.8.1/xslt_unittest.html +138 -0
  178. data/src/xslt/ajaxslt-0.8.1/xslt_unittest.js +68 -0
  179. data/src/xslt/implementation.js +625 -0
  180. data/src/xslt/processor.js +37 -0
  181. data/src/xslt/util.js +449 -0
  182. data/test/foo.html +8 -0
  183. data/test/foo.js +40 -0
  184. data/test/jquery.js +6002 -0
  185. data/test/x.js +1 -0
  186. data/test/y.js +1 -0
  187. metadata +245 -14
data/htmlparser/README ADDED
@@ -0,0 +1,34 @@
1
+ Envjs make use the awesome project 'http://about.validator.nu/htmlparser/'
2
+ which generates an HTML5 compliant parsing engine, written in Java, into
3
+ javascript via GWT.
4
+
5
+ The generated files are available in
6
+ env-js/
7
+ src/
8
+ parser/
9
+ html5.js
10
+ html5.min.js
11
+ html5.detailed.js
12
+
13
+ The various versions are simply generated with varying verbosity of source.
14
+ html.js is the most readable at 60KB, html.detailed.js is almost too verbose at
15
+ over 120KB, and finally html5.min.js is totally unreadable but weighs in at only
16
+ 30KB. By default the html5.min.js is included in Envjs releases because most
17
+ folks aren't too worried about the gory details of the parser.
18
+
19
+ The scripts in this folder can be used to checkout and download the various
20
+ components you will need to generate these yourself.
21
+
22
+ Once generated, there are a couple very small and specific changes that must be
23
+ made by hand to allow the parser to be initialized with the usual GWT hooks.
24
+
25
+ You will need to download the appropiate gwt for your platform
26
+
27
+ http://google-web-toolkit.googlecode.com/files/gwt-mac-1.5.1.tar.gz
28
+ http://google-web-toolkit.googlecode.com/files/gwt-windows-1.5.1.zip
29
+ http://google-web-toolkit.googlecode.com/files/gwt-linux-1.5.1.tar.bz2
30
+
31
+ Our scripts expect that it will be available at
32
+ env-js/
33
+ htmlparser/
34
+ gwt-1.5.1/
@@ -0,0 +1,38 @@
1
+ #!/bin/sh
2
+
3
+ svn co https://whattf.svn.cvsdude.com/htmlparser/trunk/ html5
4
+
5
+ cp BrowserTreeBuilder.java html5/gwt-src/nu/validator/htmlparser/gwt/BrowserTreeBuilder.java
6
+
7
+ cp gwt-1.5.1/gwt-dev-*.jar gwt-1.5.1/gwt-dev.jar
8
+
9
+ APPDIR=`dirname $0`/html5/;
10
+
11
+ echo $APPDIR
12
+
13
+ echo "Generating Minified HTMLParser"
14
+ java -XstartOnFirstThread -Xmx256M -cp "$APPDIR/src:$APPDIR/gwt-src:$APPDIR/super:./gwt-1.5.1/gwt-user.jar:./gwt-1.5.1/gwt-dev.jar" com.google.gwt.dev.GWTCompiler -out "build/min" "$@" nu.validator.htmlparser.HtmlParser;
15
+ cp ./build/min/nu.*.HtmlParser/nu.*.HtmlParser.nocache.js ./build/html5.min.js
16
+ perl -pi~ -e "s/if\(j\.addEventListener\)(.*)50\)/\/\*envjsedit\*\//" ./build/html5.min.js
17
+ perl -pi~ -e "s/if\(j\.removeEventListener\)/if\(false\/\*envjsedit\*\/\)/" ./build/html5.min.js
18
+ perl -pi~ -e "s/function kb\(\)/\/\*envjsedit\*\/var kb = Html5Parser = function\(\)/" ./build/html5.min.js
19
+
20
+ echo "Generating Pretty HTMLParser"
21
+ java -XstartOnFirstThread -Xmx256M -cp "$APPDIR/src:$APPDIR/gwt-src:$APPDIR/super:./gwt-1.5.1/gwt-user.jar:./gwt-1.5.1/gwt-dev.jar" com.google.gwt.dev.GWTCompiler -style PRETTY -out "build/pretty" "$@" nu.validator.htmlparser.HtmlParser;
22
+ cp ./build/pretty/nu.*.HtmlParser/nu.*.HtmlParser.nocache.js ./build/html5.pretty.js
23
+ perl -pi~ -e "s/if(.*)\((.*)doc_0\.addEventListener\)/\/\*envjsedit/s" ./build/html5.pretty.js
24
+ perl -pi~ -e "s/,\s50\);/envjsedit\*\//s" ./build/html5.pretty.js
25
+ perl -pi~ -e "s/if(.*)\((.*)doc_0\.removeEventListener\)/if\(false\/\*envjsedit\*\/\)/" ./build/html5.pretty.js
26
+ perl -pi~ -e "s/function onBodyDone\(\)/\/\*envjsedit\*\/var onBodyDone = Html5Parser = function\(\)/" ./build/html5.pretty.js
27
+
28
+ echo "Generating Detailed HTMLParser"
29
+ java -XstartOnFirstThread -Xmx256M -cp "$APPDIR/src:$APPDIR/gwt-src:$APPDIR/super:./gwt-1.5.1/gwt-user.jar:./gwt-1.5.1/gwt-dev.jar" com.google.gwt.dev.GWTCompiler -style DETAILED -out "build/detailed" "$@" nu.validator.htmlparser.HtmlParser;
30
+ cp ./build/detailed/nu.*.HtmlParser/nu.*.HtmlParser.nocache.js ./build/html5.detailed.js
31
+ perl -pi~ -e "s/if(.*)\((.*)doc\.addEventListener\)/\/\*envjsedit/s" ./build/html5.detailed.js
32
+ perl -pi~ -e "s/,\s50\);/envjsedit\*\//s" ./build/html5.detailed.js
33
+ perl -pi~ -e "s/if(.*)\((.*)doc\.removeEventListener\)/if\(false\/\*envjsedit\*\/\)/" ./build/html5.detailed.js
34
+ perl -pi~ -e "s/function onBodyDone\(\)/\/\*envjsedit\*\/var onBodyDone = Html5Parser = function\(\)/" ./build/html5.detailed.js
35
+
36
+ rm ./build/*.js~
37
+
38
+ cp ./build/html5.*.js ../src/parser/
data/jsl/jsl ADDED
Binary file
@@ -0,0 +1,129 @@
1
+ #
2
+ # Configuration File for JavaScript Lint 0.3.0
3
+ # Developed by Matthias Miller (http://www.JavaScriptLint.com)
4
+ #
5
+ # This configuration file can be used to lint a collection of scripts, or to enable
6
+ # or disable warnings for scripts that are linted via the command line.
7
+ #
8
+
9
+ ### Warnings
10
+ # Enable or disable warnings based on requirements.
11
+ # Use "+WarningName" to display or "-WarningName" to suppress.
12
+ #
13
+ +no_return_value # function {0} does not always return a value
14
+ +duplicate_formal # duplicate formal argument {0}
15
+ +equal_as_assign # test for equality (==) mistyped as assignment (=)?{0}
16
+ +var_hides_arg # variable {0} hides argument
17
+ +redeclared_var # redeclaration of {0} {1}
18
+ +anon_no_return_value # anonymous function does not always return a value
19
+ +missing_semicolon # missing semicolon
20
+ +meaningless_block # meaningless block; curly braces have no impact
21
+ +comma_separated_stmts # multiple statements separated by commas (use semicolons?)
22
+ +unreachable_code # unreachable code
23
+ +missing_break # missing break statement
24
+ +missing_break_for_last_case # missing break statement for last case in switch
25
+ +comparison_type_conv # comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==)
26
+ +inc_dec_within_stmt # increment (++) and decrement (--) operators used as part of greater statement
27
+ +useless_void # use of the void type may be unnecessary (void is always undefined)
28
+ +multiple_plus_minus # unknown order of operations for successive plus (e.g. x+++y) or minus (e.g. x---y) signs
29
+ +use_of_label # use of label
30
+ -block_without_braces # block statement without curly braces
31
+ +leading_decimal_point # leading decimal point may indicate a number or an object member
32
+ +trailing_decimal_point # trailing decimal point may indicate a number or an object member
33
+ +octal_number # leading zeros make an octal number
34
+ +nested_comment # nested comment
35
+ +misplaced_regex # regular expressions should be preceded by a left parenthesis, assignment, colon, or comma
36
+ +ambiguous_newline # unexpected end of line; it is ambiguous whether these lines are part of the same statement
37
+ -empty_statement # empty statement or extra semicolon
38
+ -missing_option_explicit # the "option explicit" control comment is missing
39
+ +partial_option_explicit # the "option explicit" control comment, if used, must be in the first script tag
40
+ +dup_option_explicit # duplicate "option explicit" control comment
41
+ +useless_assign # useless assignment
42
+ +ambiguous_nested_stmt # block statements containing block statements should use curly braces to resolve ambiguity
43
+ +ambiguous_else_stmt # the else statement could be matched with one of multiple if statements (use curly braces to indicate intent)
44
+ +missing_default_case # missing default case in switch statement
45
+ +duplicate_case_in_switch # duplicate case in switch statements
46
+ +default_not_at_end # the default case is not at the end of the switch statement
47
+ +legacy_cc_not_understood # couldn't understand control comment using /*@keyword@*/ syntax
48
+ +jsl_cc_not_understood # couldn't understand control comment using /*jsl:keyword*/ syntax
49
+ +useless_comparison # useless comparison; comparing identical expressions
50
+ +with_statement # with statement hides undeclared variables; use temporary variable instead
51
+ +trailing_comma_in_array # extra comma is not recommended in array initializers
52
+ +assign_to_function_call # assignment to a function call
53
+ +parseint_missing_radix # parseInt missing radix parameter
54
+
55
+
56
+ ### Output format
57
+ # Customize the format of the error message.
58
+ # __FILE__ indicates current file path
59
+ # __FILENAME__ indicates current file name
60
+ # __LINE__ indicates current line
61
+ # __ERROR__ indicates error message
62
+ #
63
+ # Visual Studio syntax (default):
64
+ +output-format __FILE__(__LINE__): __ERROR__
65
+ # Alternative syntax:
66
+ #+output-format __FILE__:__LINE__: __ERROR__
67
+
68
+
69
+ ### Context
70
+ # Show the in-line position of the error.
71
+ # Use "+context" to display or "-context" to suppress.
72
+ #
73
+ +context
74
+
75
+
76
+ ### Semicolons
77
+ # By default, assignments of an anonymous function to a variable or
78
+ # property (such as a function prototype) must be followed by a semicolon.
79
+ #
80
+ +lambda_assign_requires_semicolon
81
+
82
+
83
+ ### Control Comments
84
+ # Both JavaScript Lint and the JScript interpreter confuse each other with the syntax for
85
+ # the /*@keyword@*/ control comments and JScript conditional comments. (The latter is
86
+ # enabled in JScript with @cc_on@). The /*jsl:keyword*/ syntax is preferred for this reason,
87
+ # although legacy control comments are enabled by default for backward compatibility.
88
+ #
89
+ +legacy_control_comments
90
+
91
+
92
+ ### JScript Function Extensions
93
+ # JScript allows member functions to be defined like this:
94
+ # function MyObj() { /*constructor*/ }
95
+ # function MyObj.prototype.go() { /*member function*/ }
96
+ #
97
+ # It also allows events to be attached like this:
98
+ # function window::onload() { /*init page*/ }
99
+ #
100
+ # This is a Microsoft-only JavaScript extension. Enable this setting to allow them.
101
+ #
102
+ -jscript_function_extensions
103
+
104
+
105
+ ### Defining identifiers
106
+ # By default, "option explicit" is enabled on a per-file basis.
107
+ # To enable this for all files, use "+always_use_option_explicit"
108
+ -always_use_option_explicit
109
+
110
+ # Define certain identifiers of which the lint is not aware.
111
+ # (Use this in conjunction with the "undeclared identifier" warning.)
112
+ #
113
+ # Common uses for webpages might be:
114
+ #+define window
115
+ #+define document
116
+
117
+
118
+ ### Interactive
119
+ # Prompt for a keystroke before exiting.
120
+ #+pauseatend
121
+
122
+
123
+ ### Files
124
+ # Specify which files to lint
125
+ # Use "+recurse" to enable recursion (disabled by default).
126
+ # To add a set of files, use "+process FileName", "+process Folder\Path\*.js",
127
+ # or "+process Folder\Path\*.htm".
128
+ #
129
+ +process jsl-test.js
data/jsl/jsl.exe ADDED
Binary file
data/lib/envjs.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Envjs
2
2
 
3
+ VERSION = "0.2.0"
4
+
3
5
  def self.js_exception_stack e
4
6
  result = %(Exception: )+e.to_s
5
7
  e.stack.to_s.split(%(\n)).each do |line|
data/lib/envjs/env.js CHANGED
@@ -480,6 +480,12 @@ $env.lineSource = function(e){
480
480
  };
481
481
 
482
482
  $env.loadInlineScript = function(script){
483
+ var undef;
484
+ if (script.text === undef ||
485
+ script.text === null ||
486
+ script.text.match(/^\s*$/)) {
487
+ return;
488
+ }
483
489
  var original_script_window = $master.first_script_window;
484
490
  // debug("lis",original_script_window,original_script_window.isInner);
485
491
  // debug("XX",window,window.isInner);
@@ -492,6 +498,8 @@ $env.loadInlineScript = function(script){
492
498
  } catch(e) {
493
499
  $env.error("error evaluating script: "+script.text);
494
500
  $env.error(e);
501
+ // try { throw new Error("here") } catch(b) { $env.error(b.stack); }
502
+ // throw e;
495
503
  }
496
504
  // $master.first_script_window = original_script_window;
497
505
  // debug("lis",original_script_window,original_script_window.isInner);
@@ -770,6 +778,8 @@ var Envjs = function(){
770
778
  $env.onScriptLoadError = $env.onScriptLoadError || function(){};
771
779
  $env.loadLocalScript = function(script, parser){
772
780
  $env.debug("loading script ");
781
+ // print("loadloacl");
782
+ // try{throw new Error}catch(e){print(e.stack);}
773
783
  var types, type, src, i, base,
774
784
  docWrites = [],
775
785
  write = document.write,
@@ -783,7 +793,7 @@ var Envjs = function(){
783
793
  for(i=0;i<types.length;i++){
784
794
  if($env.scriptTypes[types[i]]){
785
795
  if(script.src){
786
- $env.info("loading allowed external script :" + script.src);
796
+ $env.info("loading allowed external script: " + script.src);
787
797
  //lets you register a function to execute
788
798
  //before the script is loaded
789
799
  if($env.beforeScriptLoad){
@@ -794,7 +804,7 @@ var Envjs = function(){
794
804
  }
795
805
  }
796
806
  base = "" + window.location;
797
- var filename = $env.location(script.src.match(/([^\?#]*)/)[1], base );
807
+ var filename = $env.location(script.src, base );
798
808
  try {
799
809
  load(filename);
800
810
  } catch(e) {
@@ -1074,7 +1084,14 @@ __extend__($w,{
1074
1084
  get status(){return $status;},
1075
1085
  set status(_status){$status = _status;},
1076
1086
  get top(){return $top || $window;},
1077
- get window(){return $window;} /*,
1087
+ get window(){return $window;},
1088
+
1089
+ // DOM0
1090
+
1091
+ Image: function() {
1092
+ return document.createElement("img");
1093
+ }
1094
+ /*,
1078
1095
  toString : function(){
1079
1096
  return '[object Window]';
1080
1097
  } FIX SMP */
@@ -1824,6 +1841,7 @@ $debug("Initializing Window Location.");
1824
1841
  var $location = '';
1825
1842
 
1826
1843
  $w.__defineSetter__("location", function(url){
1844
+ if (false) {
1827
1845
  if (url[0] === "#") {
1828
1846
  // print("return anchor only");
1829
1847
  return;
@@ -1849,6 +1867,7 @@ $w.__defineSetter__("location", function(url){
1849
1867
  return;
1850
1868
  }
1851
1869
  // print("ft",window.location.href,$location,url);
1870
+ }
1852
1871
  if( !$location || $location == "about:blank" ) {
1853
1872
  // $w.__loadAWindowsDocument__(url);
1854
1873
  $env.load(url);
@@ -53,6 +53,7 @@
53
53
  if (typeof fn == 'string') {
54
54
  tfn = function() {
55
55
  try {
56
+ // FIX ME: has to evaluate in inner ... probably in caller?
56
57
  eval(fn);
57
58
  } catch (e) {
58
59
  $env.error(e);
@@ -84,6 +85,7 @@
84
85
  if (typeof fn == 'string') {
85
86
  var fnstr = fn;
86
87
  fn = function() {
88
+ // FIX ME: has to evaluate in inner ... probably in caller(?)
87
89
  eval(fnstr);
88
90
  };
89
91
  }
data/lib/envjs/static.js CHANGED
@@ -4322,7 +4322,7 @@ try{
4322
4322
  return $env.location('./');
4323
4323
  },
4324
4324
  get URL(){ return this._parentWindow.location.href; },
4325
- set URL(url){ this._parentWindow.location.href = url; }
4325
+ set URL(url){ this._parentWindow.location.href = url; },
4326
4326
  });
4327
4327
 
4328
4328
  var __elementPopped__ = function(ns, name, node){
@@ -4337,17 +4337,25 @@ try{
4337
4337
  var type = ( node.type === null ) ? "text/javascript" : node.type;
4338
4338
  try{
4339
4339
  if(node.nodeName.toLowerCase() == 'script' && type == "text/javascript"){
4340
- //$env.debug("element popped: script\n"+node.xml);
4341
- // unless we're parsing in a window context, don't execute scripts
4342
- if (doc.parentWindow){
4343
- //p.replaceEntities = true;
4344
- var okay = $env.loadLocalScript(node, null);
4345
- // only fire event if we actually had something to load
4346
- if (node.src && node.src.length > 0){
4347
- var event = doc.createEvent();
4348
- event.initEvent( okay ? "load" : "error", false, false );
4349
- node.dispatchEvent( event, false );
4350
- }
4340
+ // print(node,doc.in_inner_html);
4341
+ if (doc.in_inner_html) {
4342
+ // this is a fib, but ...
4343
+ // print("ignore",node);
4344
+ // node.executed = true;
4345
+ } else {
4346
+ //$env.debug("element popped: script\n"+node.xml);
4347
+ // unless we're parsing in a window context, don't execute scripts
4348
+ // this probably doesn't do anything ...
4349
+ if (true /*doc.parentWindow && !node.ownerDocument.is_innerHTML*/){
4350
+ //p.replaceEntities = true;
4351
+ var okay = $env.loadLocalScript(node, null);
4352
+ // only fire event if we actually had something to load
4353
+ if (node.src && node.src.length > 0){
4354
+ var event = doc.createEvent();
4355
+ event.initEvent( okay ? "load" : "error", false, false );
4356
+ node.dispatchEvent( event, false );
4357
+ }
4358
+ }
4351
4359
  }
4352
4360
  }
4353
4361
  else if (node.nodeName.toLowerCase() == 'frame' ||
@@ -4402,6 +4410,12 @@ try{
4402
4410
 
4403
4411
  //$w.HTMLDocument = HTMLDocument;
4404
4412
 
4413
+ // Local Variables:
4414
+ // espresso-indent-level:4
4415
+ // c-basic-offset:4
4416
+ // tab-width:4
4417
+ // End:
4418
+
4405
4419
  $debug("Defining HTMLElement");
4406
4420
  /*
4407
4421
  * HTMLElement - DOM Level 2
@@ -4448,17 +4462,42 @@ __extend__(HTMLElement.prototype, {
4448
4462
  var doc = new HTMLDocument(this.ownerDocument.implementation,
4449
4463
  this.ownerDocument._parentWindow,
4450
4464
  "");
4451
- this.ownerDocument._parentWindow.parseHtmlDocument(html,doc,null,null,true);
4452
- var parent = doc.body;
4465
+ // print("innerHTML",html);
4466
+ // try { throw new Error; } catch(e) { print(e.stack); }
4467
+ var docstring = '<html><head></head><body>'+
4468
+ '<envjs_1234567890 xmlns="envjs_1234567890">'
4469
+ +html+
4470
+ '</envjs_1234567890>'+
4471
+ '</body></html>';
4472
+ doc.in_inner_html = true;
4473
+ this.ownerDocument._parentWindow.parseHtmlDocument(docstring,doc,null,null,true);
4474
+ var parent = doc.body.childNodes[0];
4453
4475
  while(this.firstChild != null){
4454
4476
  this.removeChild( this.firstChild );
4455
4477
  }
4456
4478
  var importedNode;
4457
- while(parent.firstChild != null){
4479
+
4480
+ var pn = this;
4481
+ while(pn.parentNode) {
4482
+ pn = pn.parentNode;
4483
+ }
4484
+ // print(this,pn,this.ownerDocument);
4485
+ try{
4486
+ if (pn === this.ownerDocument) {
4487
+ this.ownerDocument.in_inner_html = true;
4488
+ // print("yup");
4489
+ }
4490
+ while(parent.firstChild != null){
4458
4491
  importedNode = this.importNode(
4459
4492
  parent.removeChild( parent.firstChild ), true);
4460
- this.appendChild( importedNode );
4461
- }
4493
+ this.appendChild( importedNode );
4494
+ }
4495
+ } finally {
4496
+ if (pn === this.ownerDocument) {
4497
+ // print("nope");
4498
+ this.ownerDocument.in_inner_html = false;
4499
+ }
4500
+ }
4462
4501
  //Mark for garbage collection
4463
4502
  doc = null;
4464
4503
  },
@@ -4577,9 +4616,56 @@ __extend__(HTMLElement.prototype, {
4577
4616
  },
4578
4617
  onmouseup: function(event){
4579
4618
  return __eval__(this.getAttribute('onmouseup')||'', this);
4580
- }
4619
+ },
4620
+
4621
+ appendChild: function( newChild, refChild ) {
4622
+ var rv = DOMElement.prototype.appendChild.apply(this, arguments);
4623
+ var node = newChild;
4624
+ var pn = this;
4625
+ while(pn.parentNode) {
4626
+ pn = pn.parentNode;
4627
+ }
4628
+ if(pn === node.ownerDocument) {
4629
+ __exec_script_tags__(newChild);
4630
+ }
4631
+ return rv;
4632
+ }
4581
4633
  });
4582
4634
 
4635
+ var __exec_script_tags__ = function(node) {
4636
+ var $env = __ownerDocument__(node)._parentWindow.$envx;
4637
+ var doc = __ownerDocument__(node);
4638
+ var type = ( node.type === null ) ? "text/javascript" : node.type;
4639
+ // print("check exec",node,node.ownerDocument.in_inner_html);
4640
+ // print(node,node.childNodes.length);
4641
+ if(node.nodeName.toLowerCase() == 'script' && type == "text/javascript"){
4642
+ // print("check",node,node.src,node.text,node.ownerDocument.in_inner_html,doc.parentWindow,node.executed);
4643
+ if (node.ownerDocument.in_inner_html) {
4644
+ //print("ignore",node);
4645
+ node.executed = true;
4646
+ } else if (doc.parentWindow &&
4647
+ !node.ownerDocument.in_inner_html &&
4648
+ !node.executed && (
4649
+ (node.src && !node.src.match(/^\s*$/)) ||
4650
+ (node.text && !node.text.match(/^\s*$/))
4651
+ ) ) {
4652
+ node.executed = true;
4653
+ //p.replaceEntities = true;
4654
+ //print("exec",node);
4655
+ var okay = $env.loadLocalScript(node, null);
4656
+ // only fire event if we actually had something to load
4657
+ if (node.src && node.src.length > 0){
4658
+ var event = doc.createEvent();
4659
+ event.initEvent( okay ? "load" : "error", false, false );
4660
+ node.dispatchEvent( event, false );
4661
+ }
4662
+ }
4663
+ }
4664
+ for(var i=0; i < node.childNodes.length; i++) {
4665
+ __exec_script_tags__(node.childNodes[i]);
4666
+ }
4667
+ };
4668
+
4583
4669
  var __recursivelyGatherText__ = function(aNode) {
4584
4670
  var accumulateText = "";
4585
4671
  var idx; var n;
@@ -6799,6 +6885,46 @@ var HTMLScriptElement = function(ownerDocument) {
6799
6885
  };
6800
6886
  HTMLScriptElement.prototype = new HTMLElement;
6801
6887
  __extend__(HTMLScriptElement.prototype, {
6888
+ setAttribute: function(name,value) {
6889
+ var result = HTMLElement.prototype.setAttribute.apply(this,arguments);
6890
+ // print("set src",this,this.executed);
6891
+ if (name === "src" && !this.executed && value && !value.match(/^\s*$/)) {
6892
+ var pn = this;
6893
+ while(pn.parentNode) {
6894
+ pn = pn.parentNode;
6895
+ }
6896
+ if(pn === this.ownerDocument) {
6897
+ this.executed = true;
6898
+ var $env = this.ownerDocument._parentWindow.$envx;
6899
+ // print("on src change");
6900
+ $env.loadLocalScript(this);
6901
+ }
6902
+ }
6903
+ return result;
6904
+ },
6905
+
6906
+ appendChild: function(node,ref) {
6907
+ var result = HTMLElement.prototype.appendChild.apply(this,arguments);
6908
+ // print("check",this,this.ownerDocument.in_inner_html);
6909
+ if (!this.executed) {
6910
+ var pn = this;
6911
+ while(pn.parentNode) {
6912
+ pn = pn.parentNode;
6913
+ }
6914
+ if(pn === this.ownerDocument) {
6915
+ var text = this.text;
6916
+ // print("T:", text);
6917
+ if (text && !text.match(/^\s*$/)) {
6918
+ this.executed = true;
6919
+ var $env = this.ownerDocument._parentWindow.$envx;
6920
+ // print("on text change");
6921
+ $env.loadInlineScript(this);
6922
+ }
6923
+ }
6924
+ }
6925
+ return result;
6926
+ },
6927
+
6802
6928
  get text(){
6803
6929
  // text of script is in a child node of the element
6804
6930
  // scripts with < operator must be in a CDATA node
@@ -6815,9 +6941,10 @@ __extend__(HTMLScriptElement.prototype, {
6815
6941
 
6816
6942
  },
6817
6943
  set text(value){
6818
- this.nodeValue = value;
6819
- var $env = this.ownerDocument._parentWindow.$envx;
6820
- $env.loadInlineScript(this);
6944
+ while (this.firstChild) {
6945
+ this.removeChild(this.firstChild);
6946
+ }
6947
+ this.appendChild(this.ownerDocument.createTextNode(value));
6821
6948
  },
6822
6949
  get htmlFor(){
6823
6950
  return this.getAttribute('for');
@@ -6864,6 +6991,13 @@ __extend__(HTMLScriptElement.prototype, {
6864
6991
  });
6865
6992
 
6866
6993
  // $w.HTMLScriptElement = HTMLScriptElement;
6994
+
6995
+ // Local Variables:
6996
+ // espresso-indent-level:4
6997
+ // c-basic-offset:4
6998
+ // tab-width:4
6999
+ // End:
7000
+
6867
7001
  $debug("Defining HTMLSelectElement");
6868
7002
  /*
6869
7003
  * HTMLSelectElement - DOM Level 2