jbarnette-johnson 1.0.0.20090127202936 → 1.0.0.20090225110820
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MANIFEST +1 -0
- data/Rakefile +5 -4
- data/johnson.gemspec +3 -3
- data/js/johnson/browser/env.js +5 -4
- data/lib/johnson/runtime.rb +1 -1
- data/test/jquery_units/test.js +4 -0
- data/test/jquery_units/test_helper.js +1 -1
- data/test/jquery_units/units/core.js +1224 -1219
- data/vendor/spidermonkey/config.mk +4 -0
- data/vendor/spidermonkey/config/FreeBSD.mk +103 -0
- metadata +4 -2
data/MANIFEST
CHANGED
@@ -157,6 +157,7 @@ vendor/spidermonkey/config/Darwin1.3.mk
|
|
157
157
|
vendor/spidermonkey/config/Darwin1.4.mk
|
158
158
|
vendor/spidermonkey/config/Darwin5.2.mk
|
159
159
|
vendor/spidermonkey/config/Darwin5.3.mk
|
160
|
+
vendor/spidermonkey/config/FreeBSD.mk
|
160
161
|
vendor/spidermonkey/config/HP-UXB.10.10.mk
|
161
162
|
vendor/spidermonkey/config/HP-UXB.10.20.mk
|
162
163
|
vendor/spidermonkey/config/HP-UXB.11.00.mk
|
data/Rakefile
CHANGED
@@ -9,6 +9,7 @@ abort "Need Ruby version 1.8.x!" unless RUBY_VERSION > "1.8"
|
|
9
9
|
kind = Config::CONFIG["DLEXT"]
|
10
10
|
|
11
11
|
CROSS = ENV["CROSS"]
|
12
|
+
MAKE = ENV["MAKE"] || RUBY_PLATFORM =~ /freebsd/ ? 'gmake' : 'make'
|
12
13
|
LIBJS = FileList["vendor/spidermonkey/#{CROSS || ''}*.OBJ/libjs.{#{kind},so}"].first || :libjs
|
13
14
|
|
14
15
|
GENERATED_NODE = "ext/spidermonkey/immutable_node.c"
|
@@ -79,8 +80,8 @@ task :install_expat do
|
|
79
80
|
`tar -xf xmlparser-0.6.8.tar`
|
80
81
|
Dir.chdir("xmlparser") do
|
81
82
|
puts `#{Gem.ruby} extconf.rb`
|
82
|
-
puts `
|
83
|
-
puts `sudo
|
83
|
+
puts `#{MAKE}`
|
84
|
+
puts `sudo #{MAKE} install`
|
84
85
|
end
|
85
86
|
end
|
86
87
|
end
|
@@ -100,7 +101,7 @@ namespace :extensions do
|
|
100
101
|
end
|
101
102
|
|
102
103
|
build_sm = lambda do
|
103
|
-
cmd = "
|
104
|
+
cmd = "#{MAKE} -f Makefile.ref"
|
104
105
|
cmd << " OS_CONFIG=#{CROSS}" if CROSS
|
105
106
|
Dir.chdir("vendor/spidermonkey") { sh cmd }
|
106
107
|
end
|
@@ -126,7 +127,7 @@ file "ext/spidermonkey/spidermonkey.#{kind}" =>
|
|
126
127
|
["ext/spidermonkey/Makefile"] + FileList["ext/spidermonkey/*.{c,h}"].to_a do |t|
|
127
128
|
|
128
129
|
old_time = File.mtime(t.name) rescue nil
|
129
|
-
Dir.chdir("ext/spidermonkey") { sh "
|
130
|
+
Dir.chdir("ext/spidermonkey") { sh "#{MAKE}" }
|
130
131
|
|
131
132
|
# If make chose not to rebuild the file, we'll touch it, so we don't
|
132
133
|
# bother to call make again next time.
|
data/johnson.gemspec
CHANGED
@@ -2,18 +2,18 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{johnson}
|
5
|
-
s.version = "1.0.0.
|
5
|
+
s.version = "1.0.0.20090225110820"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["John Barnette", "Aaron Patterson", "Yehuda Katz", "Matthew Draper"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-02-25}
|
10
10
|
s.default_executable = %q{johnson}
|
11
11
|
s.description = %q{Johnson wraps JavaScript in a loving Ruby embrace.}
|
12
12
|
s.email = %q{johnson-talk@googlegroups.com}
|
13
13
|
s.executables = ["johnson"]
|
14
14
|
s.extensions = ["Rakefile"]
|
15
15
|
s.extra_rdoc_files = ["README.rdoc", "cross-compile.txt"]
|
16
|
-
s.files = [".autotest", "CHANGELOG", "MANIFEST", "MINGW32.mk", "README.rdoc", "Rakefile", "bin/johnson", "cross-compile.txt", "ext/spidermonkey/context.c", "ext/spidermonkey/context.h", "ext/spidermonkey/conversions.c", "ext/spidermonkey/conversions.h", "ext/spidermonkey/debugger.c", "ext/spidermonkey/debugger.h", "ext/spidermonkey/extconf.rb", "ext/spidermonkey/extensions.c", "ext/spidermonkey/extensions.h", "ext/spidermonkey/global.c", "ext/spidermonkey/global.h", "ext/spidermonkey/idhash.c", "ext/spidermonkey/idhash.h", "ext/spidermonkey/immutable_node.c", "ext/spidermonkey/immutable_node.c.erb", "ext/spidermonkey/immutable_node.h", "ext/spidermonkey/jroot.h", "ext/spidermonkey/js_land_proxy.c", "ext/spidermonkey/js_land_proxy.h", "ext/spidermonkey/ruby_land_proxy.c", "ext/spidermonkey/ruby_land_proxy.h", "ext/spidermonkey/runtime.c", "ext/spidermonkey/runtime.h", "ext/spidermonkey/spidermonkey.c", "ext/spidermonkey/spidermonkey.h", "johnson.gemspec", "js/johnson/browser.js", "js/johnson/browser/env.js", "js/johnson/browser/jquery.js", "js/johnson/browser/xmlsax.js", "js/johnson/browser/xmlw3cdom.js", "js/johnson/cli.js", "js/johnson/prelude.js", "js/johnson/template.js", "lib/hoe.rb", "lib/johnson.rb", "lib/johnson/cli.rb", "lib/johnson/cli/options.rb", "lib/johnson/error.rb", "lib/johnson/nodes.rb", "lib/johnson/nodes/binary_node.rb", "lib/johnson/nodes/for.rb", "lib/johnson/nodes/for_in.rb", "lib/johnson/nodes/function.rb", "lib/johnson/nodes/list.rb", "lib/johnson/nodes/node.rb", "lib/johnson/nodes/ternary_node.rb", "lib/johnson/parser.rb", "lib/johnson/parser/syntax_error.rb", "lib/johnson/runtime.rb", "lib/johnson/spidermonkey/context.rb", "lib/johnson/spidermonkey/debugger.rb", "lib/johnson/spidermonkey/immutable_node.rb", "lib/johnson/spidermonkey/js_land_proxy.rb", "lib/johnson/spidermonkey/mutable_tree_visitor.rb", "lib/johnson/spidermonkey/ruby_land_proxy.rb", "lib/johnson/spidermonkey/runtime.rb", "lib/johnson/version.rb", "lib/johnson/visitable.rb", "lib/johnson/visitors.rb", "lib/johnson/visitors/dot_visitor.rb", "lib/johnson/visitors/ecma_visitor.rb", "lib/johnson/visitors/enumerating_visitor.rb", "lib/johnson/visitors/sexp_visitor.rb", "lib/johnson/visitors/visitor.rb", "lib/rails/init.rb", "srcs/xmlparser-0.6.8.tar", "test/assets/index.html", "test/assets/jquery_test.html", "test/helper.rb", "test/johnson/browser_test.rb", "test/johnson/conversions/array_test.rb", "test/johnson/conversions/boolean_test.rb", "test/johnson/conversions/callable_test.rb", "test/johnson/conversions/file_test.rb", "test/johnson/conversions/nil_test.rb", "test/johnson/conversions/number_test.rb", "test/johnson/conversions/regexp_test.rb", "test/johnson/conversions/string_test.rb", "test/johnson/conversions/struct_test.rb", "test/johnson/conversions/symbol_test.rb", "test/johnson/conversions/thread_test.rb", "test/johnson/error_test.rb", "test/johnson/extensions_test.rb", "test/johnson/nodes/array_literal_test.rb", "test/johnson/nodes/array_node_test.rb", "test/johnson/nodes/binary_node_test.rb", "test/johnson/nodes/bracket_access_test.rb", "test/johnson/nodes/delete_test.rb", "test/johnson/nodes/do_while_test.rb", "test/johnson/nodes/dot_accessor_test.rb", "test/johnson/nodes/export_test.rb", "test/johnson/nodes/for_test.rb", "test/johnson/nodes/function_test.rb", "test/johnson/nodes/if_test.rb", "test/johnson/nodes/import_test.rb", "test/johnson/nodes/label_test.rb", "test/johnson/nodes/let_test.rb", "test/johnson/nodes/object_literal_test.rb", "test/johnson/nodes/return_test.rb", "test/johnson/nodes/semi_test.rb", "test/johnson/nodes/switch_test.rb", "test/johnson/nodes/ternary_test.rb", "test/johnson/nodes/throw_test.rb", "test/johnson/nodes/try_node_test.rb", "test/johnson/nodes/typeof_test.rb", "test/johnson/nodes/unary_node_test.rb", "test/johnson/nodes/void_test.rb", "test/johnson/nodes/while_test.rb", "test/johnson/nodes/with_test.rb", "test/johnson/prelude_test.rb", "test/johnson/runtime_test.rb", "test/johnson/spidermonkey/context_test.rb", "test/johnson/spidermonkey/immutable_node_test.rb", "test/johnson/spidermonkey/js_land_proxy_test.rb", "test/johnson/spidermonkey/ruby_land_proxy_test.rb", "test/johnson/spidermonkey/runtime_test.rb", "test/johnson/version_test.rb", "test/johnson/visitors/dot_visitor_test.rb", "test/johnson/visitors/enumerating_visitor_test.rb", "test/johnson_test.rb", "test/jquery_units/simple.js", "test/jquery_units/test.js", "test/jquery_units/test_helper.js", "test/jquery_units/units/ajax.js", "test/jquery_units/units/core.js", "test/jquery_units/units/event.js", "test/jquery_units/units/fx.js", "test/jquery_units/units/offset.js", "test/jquery_units/units/selector.js", "test/jspec/helper.js", "test/jspec/jspec.js", "test/jspec/simple_spec.js", "test/parser_test.rb", "todo/.keep", "vendor/spidermonkey/.cvsignore", "vendor/spidermonkey/Makefile.in", "vendor/spidermonkey/Makefile.ref", "vendor/spidermonkey/README.html", "vendor/spidermonkey/SpiderMonkey.rsp", "vendor/spidermonkey/Y.js", "vendor/spidermonkey/build.mk", "vendor/spidermonkey/config.mk", "vendor/spidermonkey/config/AIX4.1.mk", "vendor/spidermonkey/config/AIX4.2.mk", "vendor/spidermonkey/config/AIX4.3.mk", "vendor/spidermonkey/config/Darwin.mk", "vendor/spidermonkey/config/Darwin1.3.mk", "vendor/spidermonkey/config/Darwin1.4.mk", "vendor/spidermonkey/config/Darwin5.2.mk", "vendor/spidermonkey/config/Darwin5.3.mk", "vendor/spidermonkey/config/HP-UXB.10.10.mk", "vendor/spidermonkey/config/HP-UXB.10.20.mk", "vendor/spidermonkey/config/HP-UXB.11.00.mk", "vendor/spidermonkey/config/IRIX.mk", "vendor/spidermonkey/config/IRIX5.3.mk", "vendor/spidermonkey/config/IRIX6.1.mk", "vendor/spidermonkey/config/IRIX6.2.mk", "vendor/spidermonkey/config/IRIX6.3.mk", "vendor/spidermonkey/config/IRIX6.5.mk", "vendor/spidermonkey/config/Linux_All.mk", "vendor/spidermonkey/config/Mac_OS10.0.mk", "vendor/spidermonkey/config/OSF1V4.0.mk", "vendor/spidermonkey/config/OSF1V5.0.mk", "vendor/spidermonkey/config/SunOS4.1.4.mk", "vendor/spidermonkey/config/SunOS5.10.mk", "vendor/spidermonkey/config/SunOS5.3.mk", "vendor/spidermonkey/config/SunOS5.4.mk", "vendor/spidermonkey/config/SunOS5.5.1.mk", "vendor/spidermonkey/config/SunOS5.5.mk", "vendor/spidermonkey/config/SunOS5.6.mk", "vendor/spidermonkey/config/SunOS5.7.mk", "vendor/spidermonkey/config/SunOS5.8.mk", "vendor/spidermonkey/config/SunOS5.9.mk", "vendor/spidermonkey/config/WINNT4.0.mk", "vendor/spidermonkey/config/WINNT5.0.mk", "vendor/spidermonkey/config/WINNT5.1.mk", "vendor/spidermonkey/config/WINNT5.2.mk", "vendor/spidermonkey/config/WINNT6.0.mk", "vendor/spidermonkey/config/dgux.mk", "vendor/spidermonkey/editline/Makefile.ref", "vendor/spidermonkey/editline/README", "vendor/spidermonkey/editline/editline.3", "vendor/spidermonkey/editline/editline.c", "vendor/spidermonkey/editline/editline.h", "vendor/spidermonkey/editline/sysunix.c", "vendor/spidermonkey/editline/unix.h", "vendor/spidermonkey/fdlibm/.cvsignore", "vendor/spidermonkey/fdlibm/Makefile.in", "vendor/spidermonkey/fdlibm/Makefile.ref", "vendor/spidermonkey/fdlibm/e_acos.c", "vendor/spidermonkey/fdlibm/e_acosh.c", "vendor/spidermonkey/fdlibm/e_asin.c", "vendor/spidermonkey/fdlibm/e_atan2.c", "vendor/spidermonkey/fdlibm/e_atanh.c", "vendor/spidermonkey/fdlibm/e_cosh.c", "vendor/spidermonkey/fdlibm/e_exp.c", "vendor/spidermonkey/fdlibm/e_fmod.c", "vendor/spidermonkey/fdlibm/e_gamma.c", "vendor/spidermonkey/fdlibm/e_gamma_r.c", "vendor/spidermonkey/fdlibm/e_hypot.c", "vendor/spidermonkey/fdlibm/e_j0.c", "vendor/spidermonkey/fdlibm/e_j1.c", "vendor/spidermonkey/fdlibm/e_jn.c", "vendor/spidermonkey/fdlibm/e_lgamma.c", "vendor/spidermonkey/fdlibm/e_lgamma_r.c", "vendor/spidermonkey/fdlibm/e_log.c", "vendor/spidermonkey/fdlibm/e_log10.c", "vendor/spidermonkey/fdlibm/e_pow.c", "vendor/spidermonkey/fdlibm/e_rem_pio2.c", "vendor/spidermonkey/fdlibm/e_remainder.c", "vendor/spidermonkey/fdlibm/e_scalb.c", "vendor/spidermonkey/fdlibm/e_sinh.c", "vendor/spidermonkey/fdlibm/e_sqrt.c", "vendor/spidermonkey/fdlibm/fdlibm.h", "vendor/spidermonkey/fdlibm/fdlibm.mak", "vendor/spidermonkey/fdlibm/fdlibm.mdp", "vendor/spidermonkey/fdlibm/k_cos.c", "vendor/spidermonkey/fdlibm/k_rem_pio2.c", "vendor/spidermonkey/fdlibm/k_sin.c", "vendor/spidermonkey/fdlibm/k_standard.c", "vendor/spidermonkey/fdlibm/k_tan.c", "vendor/spidermonkey/fdlibm/s_asinh.c", "vendor/spidermonkey/fdlibm/s_atan.c", "vendor/spidermonkey/fdlibm/s_cbrt.c", "vendor/spidermonkey/fdlibm/s_ceil.c", "vendor/spidermonkey/fdlibm/s_copysign.c", "vendor/spidermonkey/fdlibm/s_cos.c", "vendor/spidermonkey/fdlibm/s_erf.c", "vendor/spidermonkey/fdlibm/s_expm1.c", "vendor/spidermonkey/fdlibm/s_fabs.c", "vendor/spidermonkey/fdlibm/s_finite.c", "vendor/spidermonkey/fdlibm/s_floor.c", "vendor/spidermonkey/fdlibm/s_frexp.c", "vendor/spidermonkey/fdlibm/s_ilogb.c", "vendor/spidermonkey/fdlibm/s_isnan.c", "vendor/spidermonkey/fdlibm/s_ldexp.c", "vendor/spidermonkey/fdlibm/s_lib_version.c", "vendor/spidermonkey/fdlibm/s_log1p.c", "vendor/spidermonkey/fdlibm/s_logb.c", "vendor/spidermonkey/fdlibm/s_matherr.c", "vendor/spidermonkey/fdlibm/s_modf.c", "vendor/spidermonkey/fdlibm/s_nextafter.c", "vendor/spidermonkey/fdlibm/s_rint.c", "vendor/spidermonkey/fdlibm/s_scalbn.c", "vendor/spidermonkey/fdlibm/s_signgam.c", "vendor/spidermonkey/fdlibm/s_significand.c", "vendor/spidermonkey/fdlibm/s_sin.c", "vendor/spidermonkey/fdlibm/s_tan.c", "vendor/spidermonkey/fdlibm/s_tanh.c", "vendor/spidermonkey/fdlibm/w_acos.c", "vendor/spidermonkey/fdlibm/w_acosh.c", "vendor/spidermonkey/fdlibm/w_asin.c", "vendor/spidermonkey/fdlibm/w_atan2.c", "vendor/spidermonkey/fdlibm/w_atanh.c", "vendor/spidermonkey/fdlibm/w_cosh.c", "vendor/spidermonkey/fdlibm/w_exp.c", "vendor/spidermonkey/fdlibm/w_fmod.c", "vendor/spidermonkey/fdlibm/w_gamma.c", "vendor/spidermonkey/fdlibm/w_gamma_r.c", "vendor/spidermonkey/fdlibm/w_hypot.c", "vendor/spidermonkey/fdlibm/w_j0.c", "vendor/spidermonkey/fdlibm/w_j1.c", "vendor/spidermonkey/fdlibm/w_jn.c", "vendor/spidermonkey/fdlibm/w_lgamma.c", "vendor/spidermonkey/fdlibm/w_lgamma_r.c", "vendor/spidermonkey/fdlibm/w_log.c", "vendor/spidermonkey/fdlibm/w_log10.c", "vendor/spidermonkey/fdlibm/w_pow.c", "vendor/spidermonkey/fdlibm/w_remainder.c", "vendor/spidermonkey/fdlibm/w_scalb.c", "vendor/spidermonkey/fdlibm/w_sinh.c", "vendor/spidermonkey/fdlibm/w_sqrt.c", "vendor/spidermonkey/javascript-trace.d", "vendor/spidermonkey/js.c", "vendor/spidermonkey/js.mak", "vendor/spidermonkey/js.mdp", "vendor/spidermonkey/js.msg", "vendor/spidermonkey/js3240.rc", "vendor/spidermonkey/jsOS240.def", "vendor/spidermonkey/jsapi.c", "vendor/spidermonkey/jsapi.h", "vendor/spidermonkey/jsarena.c", "vendor/spidermonkey/jsarena.h", "vendor/spidermonkey/jsarray.c", "vendor/spidermonkey/jsarray.h", "vendor/spidermonkey/jsatom.c", "vendor/spidermonkey/jsatom.h", "vendor/spidermonkey/jsbit.h", "vendor/spidermonkey/jsbool.c", "vendor/spidermonkey/jsbool.h", "vendor/spidermonkey/jsclist.h", "vendor/spidermonkey/jscntxt.c", "vendor/spidermonkey/jscntxt.h", "vendor/spidermonkey/jscompat.h", "vendor/spidermonkey/jsconfig.h", "vendor/spidermonkey/jsconfig.mk", "vendor/spidermonkey/jscpucfg.c", "vendor/spidermonkey/jscpucfg.h", "vendor/spidermonkey/jsdate.c", "vendor/spidermonkey/jsdate.h", "vendor/spidermonkey/jsdbgapi.c", "vendor/spidermonkey/jsdbgapi.h", "vendor/spidermonkey/jsdhash.c", "vendor/spidermonkey/jsdhash.h", "vendor/spidermonkey/jsdtoa.c", "vendor/spidermonkey/jsdtoa.h", "vendor/spidermonkey/jsdtracef.c", "vendor/spidermonkey/jsdtracef.h", "vendor/spidermonkey/jsemit.c", "vendor/spidermonkey/jsemit.h", "vendor/spidermonkey/jsexn.c", "vendor/spidermonkey/jsexn.h", "vendor/spidermonkey/jsfile.c", "vendor/spidermonkey/jsfile.h", "vendor/spidermonkey/jsfile.msg", "vendor/spidermonkey/jsfun.c", "vendor/spidermonkey/jsfun.h", "vendor/spidermonkey/jsgc.c", "vendor/spidermonkey/jsgc.h", "vendor/spidermonkey/jshash.c", "vendor/spidermonkey/jshash.h", "vendor/spidermonkey/jsify.pl", "vendor/spidermonkey/jsinterp.c", "vendor/spidermonkey/jsinterp.h", "vendor/spidermonkey/jsinvoke.c", "vendor/spidermonkey/jsiter.c", "vendor/spidermonkey/jsiter.h", "vendor/spidermonkey/jskeyword.tbl", "vendor/spidermonkey/jskwgen.c", "vendor/spidermonkey/jslibmath.h", "vendor/spidermonkey/jslock.c", "vendor/spidermonkey/jslock.h", "vendor/spidermonkey/jslocko.asm", "vendor/spidermonkey/jslog2.c", "vendor/spidermonkey/jslong.c", "vendor/spidermonkey/jslong.h", "vendor/spidermonkey/jsmath.c", "vendor/spidermonkey/jsmath.h", "vendor/spidermonkey/jsnum.c", "vendor/spidermonkey/jsnum.h", "vendor/spidermonkey/jsobj.c", "vendor/spidermonkey/jsobj.h", "vendor/spidermonkey/jsopcode.c", "vendor/spidermonkey/jsopcode.h", "vendor/spidermonkey/jsopcode.tbl", "vendor/spidermonkey/jsotypes.h", "vendor/spidermonkey/jsparse.c", "vendor/spidermonkey/jsparse.h", "vendor/spidermonkey/jsprf.c", "vendor/spidermonkey/jsprf.h", "vendor/spidermonkey/jsproto.tbl", "vendor/spidermonkey/jsprvtd.h", "vendor/spidermonkey/jspubtd.h", "vendor/spidermonkey/jsregexp.c", "vendor/spidermonkey/jsregexp.h", "vendor/spidermonkey/jsreops.tbl", "vendor/spidermonkey/jsscan.c", "vendor/spidermonkey/jsscan.h", "vendor/spidermonkey/jsscope.c", "vendor/spidermonkey/jsscope.h", "vendor/spidermonkey/jsscript.c", "vendor/spidermonkey/jsscript.h", "vendor/spidermonkey/jsshell.msg", "vendor/spidermonkey/jsstddef.h", "vendor/spidermonkey/jsstr.c", "vendor/spidermonkey/jsstr.h", "vendor/spidermonkey/jstypes.h", "vendor/spidermonkey/jsutil.c", "vendor/spidermonkey/jsutil.h", "vendor/spidermonkey/jsxdrapi.c", "vendor/spidermonkey/jsxdrapi.h", "vendor/spidermonkey/jsxml.c", "vendor/spidermonkey/jsxml.h", "vendor/spidermonkey/lock_SunOS.s", "vendor/spidermonkey/perfect.js", "vendor/spidermonkey/plify_jsdhash.sed", "vendor/spidermonkey/prmjtime.c", "vendor/spidermonkey/prmjtime.h", "vendor/spidermonkey/resource.h", "vendor/spidermonkey/rules.mk", "vendor/spidermonkey/win32.order"]
|
16
|
+
s.files = [".autotest", "CHANGELOG", "MANIFEST", "MINGW32.mk", "README.rdoc", "Rakefile", "bin/johnson", "cross-compile.txt", "ext/spidermonkey/context.c", "ext/spidermonkey/context.h", "ext/spidermonkey/conversions.c", "ext/spidermonkey/conversions.h", "ext/spidermonkey/debugger.c", "ext/spidermonkey/debugger.h", "ext/spidermonkey/extconf.rb", "ext/spidermonkey/extensions.c", "ext/spidermonkey/extensions.h", "ext/spidermonkey/global.c", "ext/spidermonkey/global.h", "ext/spidermonkey/idhash.c", "ext/spidermonkey/idhash.h", "ext/spidermonkey/immutable_node.c", "ext/spidermonkey/immutable_node.c.erb", "ext/spidermonkey/immutable_node.h", "ext/spidermonkey/jroot.h", "ext/spidermonkey/js_land_proxy.c", "ext/spidermonkey/js_land_proxy.h", "ext/spidermonkey/ruby_land_proxy.c", "ext/spidermonkey/ruby_land_proxy.h", "ext/spidermonkey/runtime.c", "ext/spidermonkey/runtime.h", "ext/spidermonkey/spidermonkey.c", "ext/spidermonkey/spidermonkey.h", "johnson.gemspec", "js/johnson/browser.js", "js/johnson/browser/env.js", "js/johnson/browser/jquery.js", "js/johnson/browser/xmlsax.js", "js/johnson/browser/xmlw3cdom.js", "js/johnson/cli.js", "js/johnson/prelude.js", "js/johnson/template.js", "lib/hoe.rb", "lib/johnson.rb", "lib/johnson/cli.rb", "lib/johnson/cli/options.rb", "lib/johnson/error.rb", "lib/johnson/nodes.rb", "lib/johnson/nodes/binary_node.rb", "lib/johnson/nodes/for.rb", "lib/johnson/nodes/for_in.rb", "lib/johnson/nodes/function.rb", "lib/johnson/nodes/list.rb", "lib/johnson/nodes/node.rb", "lib/johnson/nodes/ternary_node.rb", "lib/johnson/parser.rb", "lib/johnson/parser/syntax_error.rb", "lib/johnson/runtime.rb", "lib/johnson/spidermonkey/context.rb", "lib/johnson/spidermonkey/debugger.rb", "lib/johnson/spidermonkey/immutable_node.rb", "lib/johnson/spidermonkey/js_land_proxy.rb", "lib/johnson/spidermonkey/mutable_tree_visitor.rb", "lib/johnson/spidermonkey/ruby_land_proxy.rb", "lib/johnson/spidermonkey/runtime.rb", "lib/johnson/version.rb", "lib/johnson/visitable.rb", "lib/johnson/visitors.rb", "lib/johnson/visitors/dot_visitor.rb", "lib/johnson/visitors/ecma_visitor.rb", "lib/johnson/visitors/enumerating_visitor.rb", "lib/johnson/visitors/sexp_visitor.rb", "lib/johnson/visitors/visitor.rb", "lib/rails/init.rb", "srcs/xmlparser-0.6.8.tar", "test/assets/index.html", "test/assets/jquery_test.html", "test/helper.rb", "test/johnson/browser_test.rb", "test/johnson/conversions/array_test.rb", "test/johnson/conversions/boolean_test.rb", "test/johnson/conversions/callable_test.rb", "test/johnson/conversions/file_test.rb", "test/johnson/conversions/nil_test.rb", "test/johnson/conversions/number_test.rb", "test/johnson/conversions/regexp_test.rb", "test/johnson/conversions/string_test.rb", "test/johnson/conversions/struct_test.rb", "test/johnson/conversions/symbol_test.rb", "test/johnson/conversions/thread_test.rb", "test/johnson/error_test.rb", "test/johnson/extensions_test.rb", "test/johnson/nodes/array_literal_test.rb", "test/johnson/nodes/array_node_test.rb", "test/johnson/nodes/binary_node_test.rb", "test/johnson/nodes/bracket_access_test.rb", "test/johnson/nodes/delete_test.rb", "test/johnson/nodes/do_while_test.rb", "test/johnson/nodes/dot_accessor_test.rb", "test/johnson/nodes/export_test.rb", "test/johnson/nodes/for_test.rb", "test/johnson/nodes/function_test.rb", "test/johnson/nodes/if_test.rb", "test/johnson/nodes/import_test.rb", "test/johnson/nodes/label_test.rb", "test/johnson/nodes/let_test.rb", "test/johnson/nodes/object_literal_test.rb", "test/johnson/nodes/return_test.rb", "test/johnson/nodes/semi_test.rb", "test/johnson/nodes/switch_test.rb", "test/johnson/nodes/ternary_test.rb", "test/johnson/nodes/throw_test.rb", "test/johnson/nodes/try_node_test.rb", "test/johnson/nodes/typeof_test.rb", "test/johnson/nodes/unary_node_test.rb", "test/johnson/nodes/void_test.rb", "test/johnson/nodes/while_test.rb", "test/johnson/nodes/with_test.rb", "test/johnson/prelude_test.rb", "test/johnson/runtime_test.rb", "test/johnson/spidermonkey/context_test.rb", "test/johnson/spidermonkey/immutable_node_test.rb", "test/johnson/spidermonkey/js_land_proxy_test.rb", "test/johnson/spidermonkey/ruby_land_proxy_test.rb", "test/johnson/spidermonkey/runtime_test.rb", "test/johnson/version_test.rb", "test/johnson/visitors/dot_visitor_test.rb", "test/johnson/visitors/enumerating_visitor_test.rb", "test/johnson_test.rb", "test/jquery_units/simple.js", "test/jquery_units/test.js", "test/jquery_units/test_helper.js", "test/jquery_units/units/ajax.js", "test/jquery_units/units/core.js", "test/jquery_units/units/event.js", "test/jquery_units/units/fx.js", "test/jquery_units/units/offset.js", "test/jquery_units/units/selector.js", "test/jspec/helper.js", "test/jspec/jspec.js", "test/jspec/simple_spec.js", "test/parser_test.rb", "todo/.keep", "vendor/spidermonkey/.cvsignore", "vendor/spidermonkey/Makefile.in", "vendor/spidermonkey/Makefile.ref", "vendor/spidermonkey/README.html", "vendor/spidermonkey/SpiderMonkey.rsp", "vendor/spidermonkey/Y.js", "vendor/spidermonkey/build.mk", "vendor/spidermonkey/config.mk", "vendor/spidermonkey/config/AIX4.1.mk", "vendor/spidermonkey/config/AIX4.2.mk", "vendor/spidermonkey/config/AIX4.3.mk", "vendor/spidermonkey/config/Darwin.mk", "vendor/spidermonkey/config/Darwin1.3.mk", "vendor/spidermonkey/config/Darwin1.4.mk", "vendor/spidermonkey/config/Darwin5.2.mk", "vendor/spidermonkey/config/Darwin5.3.mk", "vendor/spidermonkey/config/FreeBSD.mk", "vendor/spidermonkey/config/HP-UXB.10.10.mk", "vendor/spidermonkey/config/HP-UXB.10.20.mk", "vendor/spidermonkey/config/HP-UXB.11.00.mk", "vendor/spidermonkey/config/IRIX.mk", "vendor/spidermonkey/config/IRIX5.3.mk", "vendor/spidermonkey/config/IRIX6.1.mk", "vendor/spidermonkey/config/IRIX6.2.mk", "vendor/spidermonkey/config/IRIX6.3.mk", "vendor/spidermonkey/config/IRIX6.5.mk", "vendor/spidermonkey/config/Linux_All.mk", "vendor/spidermonkey/config/Mac_OS10.0.mk", "vendor/spidermonkey/config/OSF1V4.0.mk", "vendor/spidermonkey/config/OSF1V5.0.mk", "vendor/spidermonkey/config/SunOS4.1.4.mk", "vendor/spidermonkey/config/SunOS5.10.mk", "vendor/spidermonkey/config/SunOS5.3.mk", "vendor/spidermonkey/config/SunOS5.4.mk", "vendor/spidermonkey/config/SunOS5.5.1.mk", "vendor/spidermonkey/config/SunOS5.5.mk", "vendor/spidermonkey/config/SunOS5.6.mk", "vendor/spidermonkey/config/SunOS5.7.mk", "vendor/spidermonkey/config/SunOS5.8.mk", "vendor/spidermonkey/config/SunOS5.9.mk", "vendor/spidermonkey/config/WINNT4.0.mk", "vendor/spidermonkey/config/WINNT5.0.mk", "vendor/spidermonkey/config/WINNT5.1.mk", "vendor/spidermonkey/config/WINNT5.2.mk", "vendor/spidermonkey/config/WINNT6.0.mk", "vendor/spidermonkey/config/dgux.mk", "vendor/spidermonkey/editline/Makefile.ref", "vendor/spidermonkey/editline/README", "vendor/spidermonkey/editline/editline.3", "vendor/spidermonkey/editline/editline.c", "vendor/spidermonkey/editline/editline.h", "vendor/spidermonkey/editline/sysunix.c", "vendor/spidermonkey/editline/unix.h", "vendor/spidermonkey/fdlibm/.cvsignore", "vendor/spidermonkey/fdlibm/Makefile.in", "vendor/spidermonkey/fdlibm/Makefile.ref", "vendor/spidermonkey/fdlibm/e_acos.c", "vendor/spidermonkey/fdlibm/e_acosh.c", "vendor/spidermonkey/fdlibm/e_asin.c", "vendor/spidermonkey/fdlibm/e_atan2.c", "vendor/spidermonkey/fdlibm/e_atanh.c", "vendor/spidermonkey/fdlibm/e_cosh.c", "vendor/spidermonkey/fdlibm/e_exp.c", "vendor/spidermonkey/fdlibm/e_fmod.c", "vendor/spidermonkey/fdlibm/e_gamma.c", "vendor/spidermonkey/fdlibm/e_gamma_r.c", "vendor/spidermonkey/fdlibm/e_hypot.c", "vendor/spidermonkey/fdlibm/e_j0.c", "vendor/spidermonkey/fdlibm/e_j1.c", "vendor/spidermonkey/fdlibm/e_jn.c", "vendor/spidermonkey/fdlibm/e_lgamma.c", "vendor/spidermonkey/fdlibm/e_lgamma_r.c", "vendor/spidermonkey/fdlibm/e_log.c", "vendor/spidermonkey/fdlibm/e_log10.c", "vendor/spidermonkey/fdlibm/e_pow.c", "vendor/spidermonkey/fdlibm/e_rem_pio2.c", "vendor/spidermonkey/fdlibm/e_remainder.c", "vendor/spidermonkey/fdlibm/e_scalb.c", "vendor/spidermonkey/fdlibm/e_sinh.c", "vendor/spidermonkey/fdlibm/e_sqrt.c", "vendor/spidermonkey/fdlibm/fdlibm.h", "vendor/spidermonkey/fdlibm/fdlibm.mak", "vendor/spidermonkey/fdlibm/fdlibm.mdp", "vendor/spidermonkey/fdlibm/k_cos.c", "vendor/spidermonkey/fdlibm/k_rem_pio2.c", "vendor/spidermonkey/fdlibm/k_sin.c", "vendor/spidermonkey/fdlibm/k_standard.c", "vendor/spidermonkey/fdlibm/k_tan.c", "vendor/spidermonkey/fdlibm/s_asinh.c", "vendor/spidermonkey/fdlibm/s_atan.c", "vendor/spidermonkey/fdlibm/s_cbrt.c", "vendor/spidermonkey/fdlibm/s_ceil.c", "vendor/spidermonkey/fdlibm/s_copysign.c", "vendor/spidermonkey/fdlibm/s_cos.c", "vendor/spidermonkey/fdlibm/s_erf.c", "vendor/spidermonkey/fdlibm/s_expm1.c", "vendor/spidermonkey/fdlibm/s_fabs.c", "vendor/spidermonkey/fdlibm/s_finite.c", "vendor/spidermonkey/fdlibm/s_floor.c", "vendor/spidermonkey/fdlibm/s_frexp.c", "vendor/spidermonkey/fdlibm/s_ilogb.c", "vendor/spidermonkey/fdlibm/s_isnan.c", "vendor/spidermonkey/fdlibm/s_ldexp.c", "vendor/spidermonkey/fdlibm/s_lib_version.c", "vendor/spidermonkey/fdlibm/s_log1p.c", "vendor/spidermonkey/fdlibm/s_logb.c", "vendor/spidermonkey/fdlibm/s_matherr.c", "vendor/spidermonkey/fdlibm/s_modf.c", "vendor/spidermonkey/fdlibm/s_nextafter.c", "vendor/spidermonkey/fdlibm/s_rint.c", "vendor/spidermonkey/fdlibm/s_scalbn.c", "vendor/spidermonkey/fdlibm/s_signgam.c", "vendor/spidermonkey/fdlibm/s_significand.c", "vendor/spidermonkey/fdlibm/s_sin.c", "vendor/spidermonkey/fdlibm/s_tan.c", "vendor/spidermonkey/fdlibm/s_tanh.c", "vendor/spidermonkey/fdlibm/w_acos.c", "vendor/spidermonkey/fdlibm/w_acosh.c", "vendor/spidermonkey/fdlibm/w_asin.c", "vendor/spidermonkey/fdlibm/w_atan2.c", "vendor/spidermonkey/fdlibm/w_atanh.c", "vendor/spidermonkey/fdlibm/w_cosh.c", "vendor/spidermonkey/fdlibm/w_exp.c", "vendor/spidermonkey/fdlibm/w_fmod.c", "vendor/spidermonkey/fdlibm/w_gamma.c", "vendor/spidermonkey/fdlibm/w_gamma_r.c", "vendor/spidermonkey/fdlibm/w_hypot.c", "vendor/spidermonkey/fdlibm/w_j0.c", "vendor/spidermonkey/fdlibm/w_j1.c", "vendor/spidermonkey/fdlibm/w_jn.c", "vendor/spidermonkey/fdlibm/w_lgamma.c", "vendor/spidermonkey/fdlibm/w_lgamma_r.c", "vendor/spidermonkey/fdlibm/w_log.c", "vendor/spidermonkey/fdlibm/w_log10.c", "vendor/spidermonkey/fdlibm/w_pow.c", "vendor/spidermonkey/fdlibm/w_remainder.c", "vendor/spidermonkey/fdlibm/w_scalb.c", "vendor/spidermonkey/fdlibm/w_sinh.c", "vendor/spidermonkey/fdlibm/w_sqrt.c", "vendor/spidermonkey/javascript-trace.d", "vendor/spidermonkey/js.c", "vendor/spidermonkey/js.mak", "vendor/spidermonkey/js.mdp", "vendor/spidermonkey/js.msg", "vendor/spidermonkey/js3240.rc", "vendor/spidermonkey/jsOS240.def", "vendor/spidermonkey/jsapi.c", "vendor/spidermonkey/jsapi.h", "vendor/spidermonkey/jsarena.c", "vendor/spidermonkey/jsarena.h", "vendor/spidermonkey/jsarray.c", "vendor/spidermonkey/jsarray.h", "vendor/spidermonkey/jsatom.c", "vendor/spidermonkey/jsatom.h", "vendor/spidermonkey/jsbit.h", "vendor/spidermonkey/jsbool.c", "vendor/spidermonkey/jsbool.h", "vendor/spidermonkey/jsclist.h", "vendor/spidermonkey/jscntxt.c", "vendor/spidermonkey/jscntxt.h", "vendor/spidermonkey/jscompat.h", "vendor/spidermonkey/jsconfig.h", "vendor/spidermonkey/jsconfig.mk", "vendor/spidermonkey/jscpucfg.c", "vendor/spidermonkey/jscpucfg.h", "vendor/spidermonkey/jsdate.c", "vendor/spidermonkey/jsdate.h", "vendor/spidermonkey/jsdbgapi.c", "vendor/spidermonkey/jsdbgapi.h", "vendor/spidermonkey/jsdhash.c", "vendor/spidermonkey/jsdhash.h", "vendor/spidermonkey/jsdtoa.c", "vendor/spidermonkey/jsdtoa.h", "vendor/spidermonkey/jsdtracef.c", "vendor/spidermonkey/jsdtracef.h", "vendor/spidermonkey/jsemit.c", "vendor/spidermonkey/jsemit.h", "vendor/spidermonkey/jsexn.c", "vendor/spidermonkey/jsexn.h", "vendor/spidermonkey/jsfile.c", "vendor/spidermonkey/jsfile.h", "vendor/spidermonkey/jsfile.msg", "vendor/spidermonkey/jsfun.c", "vendor/spidermonkey/jsfun.h", "vendor/spidermonkey/jsgc.c", "vendor/spidermonkey/jsgc.h", "vendor/spidermonkey/jshash.c", "vendor/spidermonkey/jshash.h", "vendor/spidermonkey/jsify.pl", "vendor/spidermonkey/jsinterp.c", "vendor/spidermonkey/jsinterp.h", "vendor/spidermonkey/jsinvoke.c", "vendor/spidermonkey/jsiter.c", "vendor/spidermonkey/jsiter.h", "vendor/spidermonkey/jskeyword.tbl", "vendor/spidermonkey/jskwgen.c", "vendor/spidermonkey/jslibmath.h", "vendor/spidermonkey/jslock.c", "vendor/spidermonkey/jslock.h", "vendor/spidermonkey/jslocko.asm", "vendor/spidermonkey/jslog2.c", "vendor/spidermonkey/jslong.c", "vendor/spidermonkey/jslong.h", "vendor/spidermonkey/jsmath.c", "vendor/spidermonkey/jsmath.h", "vendor/spidermonkey/jsnum.c", "vendor/spidermonkey/jsnum.h", "vendor/spidermonkey/jsobj.c", "vendor/spidermonkey/jsobj.h", "vendor/spidermonkey/jsopcode.c", "vendor/spidermonkey/jsopcode.h", "vendor/spidermonkey/jsopcode.tbl", "vendor/spidermonkey/jsotypes.h", "vendor/spidermonkey/jsparse.c", "vendor/spidermonkey/jsparse.h", "vendor/spidermonkey/jsprf.c", "vendor/spidermonkey/jsprf.h", "vendor/spidermonkey/jsproto.tbl", "vendor/spidermonkey/jsprvtd.h", "vendor/spidermonkey/jspubtd.h", "vendor/spidermonkey/jsregexp.c", "vendor/spidermonkey/jsregexp.h", "vendor/spidermonkey/jsreops.tbl", "vendor/spidermonkey/jsscan.c", "vendor/spidermonkey/jsscan.h", "vendor/spidermonkey/jsscope.c", "vendor/spidermonkey/jsscope.h", "vendor/spidermonkey/jsscript.c", "vendor/spidermonkey/jsscript.h", "vendor/spidermonkey/jsshell.msg", "vendor/spidermonkey/jsstddef.h", "vendor/spidermonkey/jsstr.c", "vendor/spidermonkey/jsstr.h", "vendor/spidermonkey/jstypes.h", "vendor/spidermonkey/jsutil.c", "vendor/spidermonkey/jsutil.h", "vendor/spidermonkey/jsxdrapi.c", "vendor/spidermonkey/jsxdrapi.h", "vendor/spidermonkey/jsxml.c", "vendor/spidermonkey/jsxml.h", "vendor/spidermonkey/lock_SunOS.s", "vendor/spidermonkey/perfect.js", "vendor/spidermonkey/plify_jsdhash.sed", "vendor/spidermonkey/prmjtime.c", "vendor/spidermonkey/prmjtime.h", "vendor/spidermonkey/resource.h", "vendor/spidermonkey/rules.mk", "vendor/spidermonkey/win32.order"]
|
17
17
|
s.has_rdoc = true
|
18
18
|
s.homepage = %q{http://github.com/jbarnette/johnson/wikis}
|
19
19
|
s.rdoc_options = ["--main", "README.rdoc"]
|
data/js/johnson/browser/env.js
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
var window = this;
|
9
9
|
|
10
10
|
Ruby.require("uri");
|
11
|
-
Ruby.require("
|
11
|
+
Ruby.require("taka");
|
12
12
|
|
13
13
|
print = function(txt) { Ruby.puts(txt); };
|
14
14
|
|
@@ -140,9 +140,10 @@ print = function(txt) { Ruby.puts(txt); };
|
|
140
140
|
// DOM Document
|
141
141
|
|
142
142
|
var parse = function(text) {
|
143
|
-
var parser = new Ruby.XML.DOM.Builder();
|
144
143
|
try {
|
145
|
-
|
144
|
+
// Annoying. We have to do send because HTML isn't recognized
|
145
|
+
// as a function.
|
146
|
+
return Ruby.Taka.DOM.send("HTML", text);
|
146
147
|
} catch(e) {
|
147
148
|
Ruby.puts("FAIL\n" + text);
|
148
149
|
Ruby.raise(e)
|
@@ -175,7 +176,7 @@ print = function(txt) { Ruby.puts(txt); };
|
|
175
176
|
|
176
177
|
},
|
177
178
|
getElementById: function(id){
|
178
|
-
return
|
179
|
+
return this._dom.getElementById(id);
|
179
180
|
},
|
180
181
|
get body(){
|
181
182
|
return this.getElementsByTagName("body")[0];
|
data/lib/johnson/runtime.rb
CHANGED
data/test/jquery_units/test.js
CHANGED
@@ -10,6 +10,10 @@ Johnson.waitForThreads = function() {
|
|
10
10
|
window.location = "file://" + Ruby.File.expand_path(Ruby.Dir.pwd()) + "/test/assets/jquery_test.html";
|
11
11
|
Ruby.eval("(Thread.list - [Thread.main]).each {|t| t.join}");
|
12
12
|
|
13
|
+
document = Ruby.Taka.DOM.send("HTML",
|
14
|
+
Ruby.File.open(Ruby.File.expand_path(Ruby.Dir.pwd()) + "/test/assets/jquery_test.html")
|
15
|
+
);
|
16
|
+
|
13
17
|
// Load the test runner
|
14
18
|
Johnson.require("test/jquery_units/test_helper.js");
|
15
19
|
|
@@ -3,301 +3,306 @@ module("core");
|
|
3
3
|
var isLocal = true;
|
4
4
|
|
5
5
|
test("Basic requirements", function() {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
expect(7);
|
7
|
+
ok( Array.prototype.push, "Array.push()" );
|
8
|
+
ok( Function.prototype.apply, "Function.apply()" );
|
9
|
+
ok( document.getElementById, "getElementById" );
|
10
|
+
ok( document.getElementsByTagName, "getElementsByTagName" );
|
11
|
+
ok( RegExp, "RegExp" );
|
12
|
+
ok( jQuery, "jQuery" );
|
13
|
+
ok( $, "$()" );
|
14
14
|
});
|
15
15
|
|
16
16
|
test("$()", function() {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
expect(4);
|
18
|
+
|
19
|
+
var main = $("#main");
|
20
|
+
|
21
|
+
isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );
|
22
|
+
|
23
23
|
/*
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
// disabled since this test was doing nothing. i tried to fix it but i'm not sure
|
25
|
+
// what the expected behavior should even be. FF returns "\n" for the text node
|
26
|
+
// make sure this is handled
|
27
|
+
var crlfContainer = $('<p>\r\n</p>');
|
28
|
+
var x = crlfContainer.contents().get(0).nodeValue;
|
29
|
+
equals( x, what???, "Check for \\r and \\n in jQuery()" );
|
30
30
|
*/
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
31
|
+
|
32
|
+
/* // Disabled until we add this functionality in
|
33
|
+
var pass = true;
|
34
|
+
try {
|
35
|
+
$("<div>Testing</div>").appendTo(document.getElementById("iframe").contentDocument.body);
|
36
|
+
} catch(e){
|
37
|
+
pass = false;
|
38
|
+
}
|
39
|
+
ok( pass, "$('<tag>') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/
|
40
|
+
|
41
|
+
var code = $("<code/>");
|
42
|
+
equals( code.length, 1, "Correct number of elements generated for code" );
|
43
|
+
var img = $("<img/>");
|
44
|
+
equals( img.length, 1, "Correct number of elements generated for img" );
|
45
|
+
var div = $("<div/><hr/><code/><b/>");
|
46
|
+
equals( div.length, 4, "Correct number of elements generated for div hr code b" );
|
47
47
|
});
|
48
48
|
|
49
49
|
test("browser", function() {
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
50
|
+
expect(13);
|
51
|
+
var browsers = {
|
52
|
+
//Internet Explorer
|
53
|
+
"Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)": "6.0",
|
54
|
+
"Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727)": "7.0",
|
55
|
+
/** Failing #1876
|
56
|
+
* "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30)": "7.0",
|
57
|
+
*/
|
58
|
+
//Browsers with Gecko engine
|
59
|
+
//Mozilla
|
60
|
+
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915" : "1.7.12",
|
61
|
+
//Firefox
|
62
|
+
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3": "1.8.1.3",
|
63
|
+
//Netscape
|
64
|
+
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20070321 Netscape/8.1.3" : "1.7.5",
|
65
|
+
//Flock
|
66
|
+
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.11) Gecko/20070321 Firefox/1.5.0.11 Flock/0.7.12" : "1.8.0.11",
|
67
|
+
//Opera browser
|
68
|
+
"Opera/9.20 (X11; Linux x86_64; U; en)": "9.20",
|
69
|
+
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 9.20" : "9.20",
|
70
|
+
"Mozilla/5.0 (Windows NT 5.1; U; pl; rv:1.8.0) Gecko/20060728 Firefox/1.5.0 Opera 9.20": "9.20",
|
71
|
+
//WebKit engine
|
72
|
+
"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; sv-se) AppleWebKit/418.9 (KHTML, like Gecko) Safari/419.3": "418.9",
|
73
|
+
"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.8 (KHTML, like Gecko) Safari/419.3" : "418.8",
|
74
|
+
"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; sv-se) AppleWebKit/312.8 (KHTML, like Gecko) Safari/312.5": "312.8",
|
75
|
+
//Other user agent string
|
76
|
+
"Other browser's user agent 1.0":null
|
77
|
+
};
|
78
|
+
for (var i in browsers) {
|
79
|
+
var v = i.toLowerCase().match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ); // RegEx from Core jQuery.browser.version check
|
80
|
+
version = v ? v[1] : null;
|
81
|
+
equals( version, browsers[i], "Checking UA string" );
|
82
|
+
}
|
83
83
|
});
|
84
84
|
|
85
85
|
test("noConflict", function() {
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
expect(6);
|
87
|
+
|
88
|
+
var old = jQuery;
|
89
|
+
var newjQuery = jQuery.noConflict();
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
91
|
+
ok( newjQuery == old, "noConflict returned the jQuery object" );
|
92
|
+
ok( jQuery == old, "Make sure jQuery wasn't touched." );
|
93
|
+
ok( $ == "$", "Make sure $ was reverted." );
|
94
94
|
|
95
|
-
|
95
|
+
jQuery = $ = old;
|
96
96
|
|
97
|
-
|
97
|
+
newjQuery = jQuery.noConflict(true);
|
98
98
|
|
99
|
-
|
100
|
-
|
101
|
-
|
99
|
+
ok( newjQuery == old, "noConflict returned the jQuery object" );
|
100
|
+
ok( jQuery == "jQuery", "Make sure jQuery was reverted." );
|
101
|
+
ok( $ == "$", "Make sure $ was reverted." );
|
102
102
|
|
103
|
-
|
103
|
+
jQuery = $ = old;
|
104
104
|
});
|
105
105
|
|
106
106
|
test("isFunction", function() {
|
107
|
-
|
107
|
+
expect(21);
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
109
|
+
// Make sure that false values return false
|
110
|
+
ok( !jQuery.isFunction(), "No Value" );
|
111
|
+
ok( !jQuery.isFunction( null ), "null Value" );
|
112
|
+
ok( !jQuery.isFunction( undefined ), "undefined Value" );
|
113
|
+
ok( !jQuery.isFunction( "" ), "Empty String Value" );
|
114
|
+
ok( !jQuery.isFunction( 0 ), "0 Value" );
|
115
115
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
116
|
+
// Check built-ins
|
117
|
+
// Safari uses "(Internal Function)"
|
118
|
+
ok( jQuery.isFunction(String), "String Function" );
|
119
|
+
ok( jQuery.isFunction(Array), "Array Function" );
|
120
|
+
ok( jQuery.isFunction(Object), "Object Function" );
|
121
|
+
ok( jQuery.isFunction(Function), "Function Function" );
|
122
122
|
|
123
|
-
|
124
|
-
|
125
|
-
|
123
|
+
// When stringified, this could be misinterpreted
|
124
|
+
var mystr = "function";
|
125
|
+
ok( !jQuery.isFunction(mystr), "Function String" );
|
126
126
|
|
127
|
-
|
128
|
-
|
129
|
-
|
127
|
+
// When stringified, this could be misinterpreted
|
128
|
+
var myarr = [ "function" ];
|
129
|
+
ok( !jQuery.isFunction(myarr), "Function Array" );
|
130
130
|
|
131
|
-
|
132
|
-
|
133
|
-
|
131
|
+
// When stringified, this could be misinterpreted
|
132
|
+
var myfunction = { "function": "test" };
|
133
|
+
ok( !jQuery.isFunction(myfunction), "Function Object" );
|
134
134
|
|
135
|
-
|
136
|
-
|
137
|
-
|
135
|
+
// Make sure normal functions still work
|
136
|
+
var fn = function(){};
|
137
|
+
ok( jQuery.isFunction(fn), "Normal Function" );
|
138
138
|
|
139
|
-
|
139
|
+
var obj = document.createElement("object");
|
140
140
|
|
141
|
-
|
142
|
-
|
141
|
+
// Firefox says this is a function
|
142
|
+
ok( !jQuery.isFunction(obj), "Object Element" );
|
143
143
|
|
144
|
-
|
145
|
-
|
144
|
+
// IE says this is an object
|
145
|
+
ok( jQuery.isFunction(obj.getAttribute), "getAttribute Function" );
|
146
146
|
|
147
|
-
|
147
|
+
var nodes = document.body.childNodes;
|
148
148
|
|
149
|
-
|
150
|
-
|
149
|
+
// Safari says this is a function
|
150
|
+
ok( !jQuery.isFunction(nodes), "childNodes Property" );
|
151
151
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
152
|
+
var first = document.body.firstChild;
|
153
|
+
|
154
|
+
// Normal elements are reported ok everywhere
|
155
|
+
ok( !jQuery.isFunction(first), "A normal DOM Element" );
|
156
156
|
|
157
|
-
|
158
|
-
|
159
|
-
|
157
|
+
var input = document.createElement("input");
|
158
|
+
input.type = "text";
|
159
|
+
document.body.appendChild( input );
|
160
160
|
|
161
|
-
|
162
|
-
|
161
|
+
// IE says this is an object
|
162
|
+
ok( jQuery.isFunction(input.focus), "A default function property" );
|
163
163
|
|
164
|
-
|
164
|
+
document.body.removeChild( input );
|
165
165
|
|
166
|
-
|
167
|
-
|
168
|
-
|
166
|
+
var a = document.createElement("a");
|
167
|
+
a.href = "some-function";
|
168
|
+
document.body.appendChild( a );
|
169
169
|
|
170
|
-
|
171
|
-
|
170
|
+
// This serializes with the word 'function' in it
|
171
|
+
ok( !jQuery.isFunction(a), "Anchor Element" );
|
172
172
|
|
173
|
-
|
173
|
+
document.body.removeChild( a );
|
174
174
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
175
|
+
// Recursive function calls have lengths and array-like properties
|
176
|
+
function callme(callback){
|
177
|
+
function fn(response){
|
178
|
+
callback(response);
|
179
|
+
}
|
180
180
|
|
181
|
-
|
181
|
+
ok( jQuery.isFunction(fn), "Recursive Function Call" );
|
182
182
|
|
183
|
-
|
184
|
-
|
183
|
+
fn({ some: "data" });
|
184
|
+
};
|
185
185
|
|
186
|
-
|
187
|
-
|
188
|
-
|
186
|
+
callme(function(){
|
187
|
+
callme(function(){});
|
188
|
+
});
|
189
189
|
});
|
190
190
|
|
191
191
|
var foo = false;
|
192
192
|
|
193
193
|
test("$('html')", function() {
|
194
|
-
|
194
|
+
expect(6);
|
195
195
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
196
|
+
reset();
|
197
|
+
foo = false;
|
198
|
+
var s = $("<script>var foo='test';</script>")[0];
|
199
|
+
ok( s, "Creating a script" );
|
200
|
+
ok( !foo, "Make sure the script wasn't executed prematurely" );
|
201
|
+
$("body").append(s);
|
202
|
+
ok( foo, "Executing a scripts contents in the right context" );
|
203
|
+
|
204
|
+
reset();
|
205
|
+
ok( $("<link rel='stylesheet'/>")[0], "Creating a link" );
|
206
|
+
|
207
|
+
reset();
|
208
208
|
|
209
|
-
|
210
|
-
|
209
|
+
var j = $("<span>hi</span> there <!-- mon ami -->");
|
210
|
+
ok( j.length >= 2, "Check node,textnode,comment creation (some browsers delete comments)" );
|
211
211
|
|
212
|
-
|
212
|
+
// FIXME I have no idea what is wrong with this
|
213
|
+
ok( !$("<option>test</option>")[0].selected, "Make sure that options are auto-selected #2050" );
|
213
214
|
});
|
214
215
|
|
215
216
|
test("$('html', context)", function() {
|
216
|
-
|
217
|
+
expect(1);
|
217
218
|
|
218
|
-
|
219
|
-
|
220
|
-
|
219
|
+
var $div = $("<div/>");
|
220
|
+
var $span = $("<span/>", $div);
|
221
|
+
equals($span.length, 1, "Verify a span created with a div context works, #1763");
|
221
222
|
});
|
222
223
|
|
223
224
|
if ( !isLocal ) {
|
224
225
|
test("$(selector, xml).text(str) - Loaded via XML document", function() {
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
226
|
+
expect(2);
|
227
|
+
stop();
|
228
|
+
$.get('data/dashboard.xml', function(xml) {
|
229
|
+
// tests for #1419 where IE was a problem
|
230
|
+
equals( $("tab:first", xml).text(), "blabla", "Verify initial text correct" );
|
231
|
+
$("tab:first", xml).text("newtext");
|
232
|
+
equals( $("tab:first", xml).text(), "newtext", "Verify new text correct" );
|
233
|
+
start();
|
234
|
+
});
|
234
235
|
});
|
235
236
|
}
|
236
237
|
|
237
238
|
test("length", function() {
|
238
|
-
|
239
|
-
|
239
|
+
expect(1);
|
240
|
+
ok( $("p").length == 6, "Get Number of Elements Found" );
|
240
241
|
});
|
241
242
|
|
242
243
|
test("size()", function() {
|
243
|
-
|
244
|
-
|
244
|
+
expect(1);
|
245
|
+
ok( $("p").size() == 6, "Get Number of Elements Found" );
|
245
246
|
});
|
246
247
|
|
247
248
|
test("get()", function() {
|
248
|
-
|
249
|
-
|
249
|
+
expect(1);
|
250
|
+
isSet( $("p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );
|
250
251
|
});
|
251
252
|
|
252
253
|
test("get(Number)", function() {
|
253
|
-
|
254
|
-
|
254
|
+
expect(1);
|
255
|
+
ok( $("p").get(0) == document.getElementById("firstp"), "Get A Single Element" );
|
255
256
|
});
|
256
257
|
|
257
258
|
test("add(String|Element|Array|undefined)", function() {
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
259
|
+
expect(8);
|
260
|
+
isSet( $("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );
|
261
|
+
isSet( $("#sndp").add( $("#en")[0] ).add( $("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" );
|
262
|
+
|
263
|
+
// FIXME wtf. for some reason, this totally breaks. I have
|
264
|
+
// no idea why... The problem boils down to this line though:
|
265
|
+
// $("#form");
|
266
|
+
ok( $([]).add($("#form")[0].elements).length >= 13, "Check elements from array" );
|
267
|
+
|
268
|
+
// For the time being, we're discontinuing support for $(form.elements) since it's ambiguous in IE
|
269
|
+
// use $([]).add(form.elements) instead.
|
270
|
+
//equals( $([]).add($("#form")[0].elements).length, $($("#form")[0].elements).length, "Array in constructor must equals array in add()" );
|
271
|
+
|
272
|
+
var x = $([]).add($("<p id='x1'>xxx</p>")).add($("<p id='x2'>xxx</p>"));
|
273
|
+
ok( x[0].id == "x1", "Check on-the-fly element1" );
|
274
|
+
ok( x[1].id == "x2", "Check on-the-fly element2" );
|
275
|
+
|
276
|
+
var x = $([]).add("<p id='x1'>xxx</p>").add("<p id='x2'>xxx</p>");
|
277
|
+
ok( x[0].id == "x1", "Check on-the-fly element1" );
|
278
|
+
ok( x[1].id == "x2", "Check on-the-fly element2" );
|
279
|
+
|
280
|
+
var notDefined;
|
281
|
+
equals( $([]).add(notDefined).length, 0, "Check that undefined adds nothing." );
|
277
282
|
});
|
278
283
|
|
279
284
|
test("each(Function)", function() {
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
285
|
+
expect(1);
|
286
|
+
var div = $("div");
|
287
|
+
div.each(function(){this.foo = 'zoo';});
|
288
|
+
var pass = true;
|
289
|
+
for ( var i = 0; i < div.size(); i++ ) {
|
290
|
+
if ( div.get(i).foo != "zoo" ) pass = false;
|
291
|
+
}
|
292
|
+
ok( pass, "Execute a function, Relative" );
|
288
293
|
});
|
289
294
|
|
290
295
|
test("index(Object)", function() {
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
296
|
+
expect(8);
|
297
|
+
ok( $([window, document]).index(window) == 0, "Check for index of elements" );
|
298
|
+
ok( $([window, document]).index(document) == 1, "Check for index of elements" );
|
299
|
+
var inputElements = $('#radio1,#radio2,#check1,#check2');
|
300
|
+
ok( inputElements.index(document.getElementById('radio1')) == 0, "Check for index of elements" );
|
301
|
+
ok( inputElements.index(document.getElementById('radio2')) == 1, "Check for index of elements" );
|
302
|
+
ok( inputElements.index(document.getElementById('check1')) == 2, "Check for index of elements" );
|
303
|
+
ok( inputElements.index(document.getElementById('check2')) == 3, "Check for index of elements" );
|
304
|
+
ok( inputElements.index(window) == -1, "Check for not found index" );
|
305
|
+
ok( inputElements.index(document) == -1, "Check for not found index" );
|
301
306
|
});
|
302
307
|
|
303
308
|
test("attr(String)", function() {
|
@@ -327,776 +332,776 @@ test("attr(String)", function() {
|
|
327
332
|
});
|
328
333
|
|
329
334
|
if ( !isLocal ) {
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
335
|
+
test("attr(String) in XML Files", function() {
|
336
|
+
expect(2);
|
337
|
+
stop();
|
338
|
+
$.get("data/dashboard.xml", function(xml) {
|
339
|
+
ok( $("locations", xml).attr("class") == "foo", "Check class attribute in XML document" );
|
340
|
+
ok( $("location", xml).attr("for") == "bar", "Check for attribute in XML document" );
|
341
|
+
start();
|
342
|
+
});
|
343
|
+
});
|
339
344
|
}
|
340
345
|
|
341
346
|
test("attr(String, Function)", function() {
|
342
|
-
|
343
|
-
|
344
|
-
|
347
|
+
expect(2);
|
348
|
+
ok( $('#text1').attr('value', function() { return this.id })[0].value == "text1", "Set value from id" );
|
349
|
+
ok( $('#text1').attr('title', function(i) { return i }).attr('title') == "0", "Set value with an index");
|
345
350
|
});
|
346
351
|
|
347
352
|
test("attr(Hash)", function() {
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
353
|
+
expect(1);
|
354
|
+
var pass = true;
|
355
|
+
$("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){
|
356
|
+
if ( this.getAttribute('foo') != "baz" && this.getAttribute('zoo') != "ping" ) pass = false;
|
357
|
+
});
|
358
|
+
ok( pass, "Set Multiple Attributes" );
|
354
359
|
});
|
355
360
|
|
356
361
|
test("attr(String, Object)", function() {
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
362
|
+
expect(17);
|
363
|
+
var div = $("div");
|
364
|
+
div.attr("foo", "bar");
|
365
|
+
var pass = true;
|
366
|
+
for ( var i = 0; i < div.size(); i++ ) {
|
367
|
+
if ( div.get(i).getAttribute('foo') != "bar" ) pass = false;
|
368
|
+
}
|
369
|
+
ok( pass, "Set Attribute" );
|
370
|
+
|
371
|
+
ok( $("#foo").attr({"width": null}), "Try to set an attribute to nothing" );
|
372
|
+
|
373
|
+
$("#name").attr('name', 'something');
|
374
|
+
ok( $("#name").attr('name') == 'something', 'Set name attribute' );
|
375
|
+
$("#check2").attr('checked', true);
|
376
|
+
ok( document.getElementById('check2').checked == true, 'Set checked attribute' );
|
377
|
+
$("#check2").attr('checked', false);
|
378
|
+
ok( document.getElementById('check2').checked == false, 'Set checked attribute' );
|
379
|
+
$("#text1").attr('readonly', true);
|
380
|
+
ok( document.getElementById('text1').readOnly == true, 'Set readonly attribute' );
|
381
|
+
$("#text1").attr('readonly', false);
|
382
|
+
ok( document.getElementById('text1').readOnly == false, 'Set readonly attribute' );
|
383
|
+
$("#name").attr('maxlength', '5');
|
384
|
+
ok( document.getElementById('name').maxLength == '5', 'Set maxlength attribute' );
|
385
|
+
$("#name").attr('maxLength', '10');
|
386
|
+
ok( document.getElementById('name').maxLength == '10', 'Set maxlength attribute' );
|
387
|
+
|
388
|
+
// for #1070
|
389
|
+
$("#name").attr('someAttr', '0');
|
390
|
+
equals( $("#name").attr('someAttr'), '0', 'Set attribute to a string of "0"' );
|
391
|
+
$("#name").attr('someAttr', 0);
|
392
|
+
equals( $("#name").attr('someAttr'), 0, 'Set attribute to the number 0' );
|
393
|
+
$("#name").attr('someAttr', 1);
|
394
|
+
equals( $("#name").attr('someAttr'), 1, 'Set attribute to the number 1' );
|
395
|
+
|
396
|
+
// using contents will get comments regular, text, and comment nodes
|
397
|
+
var j = $("#nonnodes").contents();
|
398
|
+
|
399
|
+
j.attr("name", "attrvalue");
|
400
|
+
equals( j.attr("name"), "attrvalue", "Check node,textnode,comment for attr" );
|
401
|
+
j.removeAttr("name")
|
402
|
+
|
403
|
+
reset();
|
404
|
+
|
405
|
+
var type = $("#check2").attr('type');
|
406
|
+
var thrown = false;
|
407
|
+
try {
|
408
|
+
$("#check2").attr('type','hidden');
|
409
|
+
} catch(e) {
|
410
|
+
thrown = true;
|
411
|
+
}
|
412
|
+
ok( thrown, "Exception thrown when trying to change type property" );
|
413
|
+
equals( type, $("#check2").attr('type'), "Verify that you can't change the type of an input element" );
|
414
|
+
|
415
|
+
var check = document.createElement("input");
|
416
|
+
var thrown = true;
|
417
|
+
try {
|
418
|
+
$(check).attr('type','checkbox');
|
419
|
+
} catch(e) {
|
420
|
+
thrown = false;
|
421
|
+
}
|
422
|
+
ok( thrown, "Exception thrown when trying to change type property" );
|
423
|
+
equals( "checkbox", $(check).attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );
|
419
424
|
});
|
420
425
|
|
421
426
|
if ( !isLocal ) {
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
427
|
+
test("attr(String, Object) - Loaded via XML document", function() {
|
428
|
+
expect(2);
|
429
|
+
stop();
|
430
|
+
$.get('data/dashboard.xml', function(xml) {
|
431
|
+
var titles = [];
|
432
|
+
$('tab', xml).each(function() {
|
433
|
+
titles.push($(this).attr('title'));
|
434
|
+
});
|
435
|
+
equals( titles[0], 'Location', 'attr() in XML context: Check first title' );
|
436
|
+
equals( titles[1], 'Users', 'attr() in XML context: Check second title' );
|
437
|
+
start();
|
438
|
+
});
|
439
|
+
});
|
435
440
|
}
|
436
441
|
|
437
442
|
test("css(String|Hash)", function() {
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
443
|
+
expect(19);
|
444
|
+
|
445
|
+
ok( $('#main').css("display") == 'none', 'Check for css property "display"');
|
446
|
+
|
447
|
+
ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
|
448
|
+
$('#foo').css({display: 'none'});
|
449
|
+
ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
|
450
|
+
$('#foo').css({display: 'block'});
|
451
|
+
ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
|
452
|
+
|
453
|
+
$('#floatTest').css({styleFloat: 'right'});
|
454
|
+
ok( $('#floatTest').css('styleFloat') == 'right', 'Modified CSS float using "styleFloat": Assert float is right');
|
455
|
+
$('#floatTest').css({cssFloat: 'left'});
|
456
|
+
ok( $('#floatTest').css('cssFloat') == 'left', 'Modified CSS float using "cssFloat": Assert float is left');
|
457
|
+
$('#floatTest').css({'float': 'right'});
|
458
|
+
ok( $('#floatTest').css('float') == 'right', 'Modified CSS float using "float": Assert float is right');
|
459
|
+
$('#floatTest').css({'font-size': '30px'});
|
460
|
+
ok( $('#floatTest').css('font-size') == '30px', 'Modified CSS font-size: Assert font-size is 30px');
|
461
|
+
|
462
|
+
$.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
|
463
|
+
$('#foo').css({opacity: n});
|
464
|
+
ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
|
465
|
+
$('#foo').css({opacity: parseFloat(n)});
|
466
|
+
ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
|
467
|
+
});
|
468
|
+
$('#foo').css({opacity: ''});
|
469
|
+
ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" );
|
465
470
|
});
|
466
471
|
|
467
472
|
test("css(String, Object)", function() {
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
473
|
+
expect(21);
|
474
|
+
ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
|
475
|
+
$('#foo').css('display', 'none');
|
476
|
+
ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
|
477
|
+
$('#foo').css('display', 'block');
|
478
|
+
ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
|
479
|
+
|
480
|
+
$('#floatTest').css('styleFloat', 'left');
|
481
|
+
ok( $('#floatTest').css('styleFloat') == 'left', 'Modified CSS float using "styleFloat": Assert float is left');
|
482
|
+
$('#floatTest').css('cssFloat', 'right');
|
483
|
+
ok( $('#floatTest').css('cssFloat') == 'right', 'Modified CSS float using "cssFloat": Assert float is right');
|
484
|
+
$('#floatTest').css('float', 'left');
|
485
|
+
ok( $('#floatTest').css('float') == 'left', 'Modified CSS float using "float": Assert float is left');
|
486
|
+
$('#floatTest').css('font-size', '20px');
|
487
|
+
ok( $('#floatTest').css('font-size') == '20px', 'Modified CSS font-size: Assert font-size is 20px');
|
488
|
+
|
489
|
+
$.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
|
490
|
+
$('#foo').css('opacity', n);
|
491
|
+
ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
|
492
|
+
$('#foo').css('opacity', parseFloat(n));
|
493
|
+
ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
|
494
|
+
});
|
495
|
+
$('#foo').css('opacity', '');
|
496
|
+
ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" );
|
497
|
+
// for #1438, IE throws JS error when filter exists but doesn't have opacity in it
|
498
|
+
if (jQuery.browser.msie) {
|
499
|
+
$('#foo').css("filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');");
|
500
|
+
}
|
501
|
+
equals( $('#foo').css('opacity'), '1', "Assert opacity is 1 when a different filter is set in IE, #1438" );
|
502
|
+
|
503
|
+
// using contents will get comments regular, text, and comment nodes
|
504
|
+
var j = $("#nonnodes").contents();
|
505
|
+
j.css("padding-left", "1px");
|
506
|
+
equals( j.css("padding-left"), "1px", "Check node,textnode,comment css works" );
|
507
|
+
|
508
|
+
// opera sometimes doesn't update 'display' correctly, see #2037
|
509
|
+
$("#t2037")[0].innerHTML = $("#t2037")[0].innerHTML
|
510
|
+
equals( $("#t2037 .hidden").css("display"), "none", "Make sure browser thinks it is hidden" );
|
506
511
|
});
|
507
512
|
|
508
513
|
test("jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function () {
|
509
|
-
|
514
|
+
expect(4);
|
510
515
|
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
516
|
+
var $checkedtest = $("#checkedtest");
|
517
|
+
// IE6 was clearing "checked" in jQuery.css(elem, "height");
|
518
|
+
jQuery.css($checkedtest[0], "height");
|
519
|
+
ok( !! $(":radio:first", $checkedtest).attr("checked"), "Check first radio still checked." );
|
520
|
+
ok( ! $(":radio:last", $checkedtest).attr("checked"), "Check last radio still NOT checked." );
|
521
|
+
ok( !! $(":checkbox:first", $checkedtest).attr("checked"), "Check first checkbox still checked." );
|
522
|
+
ok( ! $(":checkbox:last", $checkedtest).attr("checked"), "Check last checkbox still NOT checked." );
|
518
523
|
});
|
519
524
|
|
520
525
|
test("width()", function() {
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
526
|
+
expect(9);
|
527
|
+
|
528
|
+
var $div = $("#nothiddendiv");
|
529
|
+
$div.width(30);
|
530
|
+
equals($div.width(), 30, "Test set to 30 correctly");
|
531
|
+
$div.width(-1); // handle negative numbers by ignoring #1599
|
532
|
+
equals($div.width(), 30, "Test negative width ignored");
|
533
|
+
$div.css("padding", "20px");
|
534
|
+
equals($div.width(), 30, "Test padding specified with pixels");
|
535
|
+
$div.css("border", "2px solid #fff");
|
536
|
+
equals($div.width(), 30, "Test border specified with pixels");
|
537
|
+
$div.css("padding", "2em");
|
538
|
+
equals($div.width(), 30, "Test padding specified with ems");
|
539
|
+
$div.css("border", "1em solid #fff");
|
540
|
+
equals($div.width(), 30, "Test border specified with ems");
|
541
|
+
$div.css("padding", "2%");
|
542
|
+
equals($div.width(), 30, "Test padding specified with percent");
|
543
|
+
$div.hide();
|
544
|
+
equals($div.width(), 30, "Test hidden div");
|
545
|
+
|
546
|
+
$div.css({ display: "", border: "", padding: "" });
|
547
|
+
|
548
|
+
$("#nothiddendivchild").css({ padding: "3px", border: "2px solid #fff" });
|
549
|
+
equals($("#nothiddendivchild").width(), 20, "Test child width with border and padding");
|
550
|
+
$("#nothiddendiv, #nothiddendivchild").css({ border: "", padding: "", width: "" });
|
546
551
|
});
|
547
552
|
|
548
553
|
test("height()", function() {
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
554
|
+
expect(8);
|
555
|
+
|
556
|
+
var $div = $("#nothiddendiv");
|
557
|
+
$div.height(30);
|
558
|
+
equals($div.height(), 30, "Test set to 30 correctly");
|
559
|
+
$div.height(-1); // handle negative numbers by ignoring #1599
|
560
|
+
equals($div.height(), 30, "Test negative height ignored");
|
561
|
+
$div.css("padding", "20px");
|
562
|
+
equals($div.height(), 30, "Test padding specified with pixels");
|
563
|
+
$div.css("border", "2px solid #fff");
|
564
|
+
equals($div.height(), 30, "Test border specified with pixels");
|
565
|
+
$div.css("padding", "2em");
|
566
|
+
equals($div.height(), 30, "Test padding specified with ems");
|
567
|
+
$div.css("border", "1em solid #fff");
|
568
|
+
equals($div.height(), 30, "Test border specified with ems");
|
569
|
+
$div.css("padding", "2%");
|
570
|
+
equals($div.height(), 30, "Test padding specified with percent");
|
571
|
+
$div.hide();
|
572
|
+
equals($div.height(), 30, "Test hidden div");
|
573
|
+
|
574
|
+
$div.css({ display: "", border: "", padding: "", height: "1px" });
|
570
575
|
});
|
571
576
|
|
572
577
|
test("text()", function() {
|
573
|
-
|
574
|
-
|
575
|
-
|
578
|
+
expect(1);
|
579
|
+
var expected = "This link has class=\"blog\": Simon Willison's Weblog";
|
580
|
+
ok( $('#sap').text() == expected, 'Check for merged text of more then one element.' );
|
576
581
|
});
|
577
582
|
|
578
583
|
test("wrap(String|Element)", function() {
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
584
|
+
expect(8);
|
585
|
+
var defaultText = 'Try them out:'
|
586
|
+
var result = $('#first').wrap('<div class="red"><span></span></div>').text();
|
587
|
+
ok( defaultText == result, 'Check for wrapping of on-the-fly html' );
|
588
|
+
ok( $('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
|
589
|
+
|
590
|
+
reset();
|
591
|
+
var defaultText = 'Try them out:'
|
592
|
+
var result = $('#first').wrap(document.getElementById('empty')).parent();
|
593
|
+
ok( result.is('ol'), 'Check for element wrapping' );
|
594
|
+
ok( result.text() == defaultText, 'Check for element wrapping' );
|
595
|
+
|
596
|
+
reset();
|
597
|
+
$('#check1').click(function() {
|
598
|
+
var checkbox = this;
|
599
|
+
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
|
600
|
+
$(checkbox).wrap( '<div id="c1" style="display:none;"></div>' );
|
601
|
+
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
|
602
|
+
}).click();
|
603
|
+
|
604
|
+
// using contents will get comments regular, text, and comment nodes
|
605
|
+
var j = $("#nonnodes").contents();
|
606
|
+
j.wrap("<i></i>");
|
607
|
+
equals( $("#nonnodes > i").length, 3, "Check node,textnode,comment wraps ok" );
|
608
|
+
equals( $("#nonnodes > i").text(), j.text() + j[1].nodeValue, "Check node,textnode,comment wraps doesn't hurt text" );
|
604
609
|
});
|
605
610
|
|
606
611
|
test("wrapAll(String|Element)", function() {
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
612
|
+
expect(8);
|
613
|
+
var prev = $("#first")[0].previousSibling;
|
614
|
+
var p = $("#first")[0].parentNode;
|
615
|
+
var result = $('#first,#firstp').wrapAll('<div class="red"><div id="tmp"></div></div>');
|
616
|
+
equals( result.parent().length, 1, 'Check for wrapping of on-the-fly html' );
|
617
|
+
ok( $('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
|
618
|
+
ok( $('#firstp').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
|
619
|
+
equals( $("#first").parent().parent()[0].previousSibling, prev, "Correct Previous Sibling" );
|
620
|
+
equals( $("#first").parent().parent()[0].parentNode, p, "Correct Parent" );
|
621
|
+
|
622
|
+
reset();
|
623
|
+
var prev = $("#first")[0].previousSibling;
|
624
|
+
var p = $("#first")[0].parentNode;
|
625
|
+
var result = $('#first,#firstp').wrapAll(document.getElementById('empty'));
|
626
|
+
equals( $("#first").parent()[0], $("#firstp").parent()[0], "Same Parent" );
|
627
|
+
equals( $("#first").parent()[0].previousSibling, prev, "Correct Previous Sibling" );
|
628
|
+
equals( $("#first").parent()[0].parentNode, p, "Correct Parent" );
|
624
629
|
});
|
625
630
|
|
626
631
|
test("wrapInner(String|Element)", function() {
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
632
|
+
expect(6);
|
633
|
+
var num = $("#first").children().length;
|
634
|
+
var result = $('#first').wrapInner('<div class="red"><div id="tmp"></div></div>');
|
635
|
+
equals( $("#first").children().length, 1, "Only one child" );
|
636
|
+
ok( $("#first").children().is(".red"), "Verify Right Element" );
|
637
|
+
equals( $("#first").children().children().children().length, num, "Verify Elements Intact" );
|
633
638
|
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
639
|
+
reset();
|
640
|
+
var num = $("#first").children().length;
|
641
|
+
var result = $('#first').wrapInner(document.getElementById('empty'));
|
642
|
+
equals( $("#first").children().length, 1, "Only one child" );
|
643
|
+
ok( $("#first").children().is("#empty"), "Verify Right Element" );
|
644
|
+
equals( $("#first").children().children().length, num, "Verify Elements Intact" );
|
640
645
|
});
|
641
646
|
|
642
647
|
test("append(String|Element|Array<Element>|jQuery)", function() {
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
648
|
+
expect(21);
|
649
|
+
var defaultText = 'Try them out:'
|
650
|
+
var result = $('#first').append('<b>buga</b>');
|
651
|
+
ok( result.text() == defaultText + 'buga', 'Check if text appending works' );
|
652
|
+
ok( $('#select3').append('<option value="appendTest">Append Test</option>').find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');
|
653
|
+
|
654
|
+
reset();
|
655
|
+
var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
|
656
|
+
$('#sap').append(document.getElementById('first'));
|
657
|
+
ok( expected == $('#sap').text(), "Check for appending of element" );
|
658
|
+
|
659
|
+
reset();
|
660
|
+
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
|
661
|
+
$('#sap').append([document.getElementById('first'), document.getElementById('yahoo')]);
|
662
|
+
ok( expected == $('#sap').text(), "Check for appending of array of elements" );
|
663
|
+
|
664
|
+
reset();
|
665
|
+
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
|
666
|
+
$('#sap').append($("#first, #yahoo"));
|
667
|
+
ok( expected == $('#sap').text(), "Check for appending of jQuery object" );
|
668
|
+
|
669
|
+
reset();
|
670
|
+
$("#sap").append( 5 );
|
671
|
+
ok( $("#sap")[0].innerHTML.match( /5$/ ), "Check for appending a number" );
|
672
|
+
|
673
|
+
reset();
|
674
|
+
$("#sap").append( " text with spaces " );
|
675
|
+
ok( $("#sap")[0].innerHTML.match(/ text with spaces $/), "Check for appending text with spaces" );
|
676
|
+
|
677
|
+
reset();
|
678
|
+
ok( $("#sap").append([]), "Check for appending an empty array." );
|
679
|
+
ok( $("#sap").append(""), "Check for appending an empty string." );
|
680
|
+
ok( $("#sap").append(document.getElementsByTagName("foo")), "Check for appending an empty nodelist." );
|
681
|
+
|
682
|
+
reset();
|
683
|
+
$("#sap").append(document.getElementById('form'));
|
684
|
+
ok( $("#sap>form").size() == 1, "Check for appending a form" ); // Bug #910
|
685
|
+
|
686
|
+
reset();
|
687
|
+
var pass = true;
|
688
|
+
try {
|
689
|
+
$( $("#iframe")[0].contentWindow.document.body ).append("<div>test</div>");
|
690
|
+
} catch(e) {
|
691
|
+
pass = false;
|
692
|
+
}
|
693
|
+
|
694
|
+
ok( pass, "Test for appending a DOM node to the contents of an IFrame" );
|
695
|
+
|
696
|
+
reset();
|
697
|
+
$('<fieldset/>').appendTo('#form').append('<legend id="legend">test</legend>');
|
698
|
+
t( 'Append legend', '#legend', ['legend'] );
|
699
|
+
|
700
|
+
reset();
|
701
|
+
$('#select1').append('<OPTION>Test</OPTION>');
|
702
|
+
ok( $('#select1 option:last').text() == "Test", "Appending <OPTION> (all caps)" );
|
703
|
+
|
704
|
+
$('#table').append('<colgroup></colgroup>');
|
705
|
+
ok( $('#table colgroup').length, "Append colgroup" );
|
706
|
+
|
707
|
+
$('#table colgroup').append('<col/>');
|
708
|
+
ok( $('#table colgroup col').length, "Append col" );
|
709
|
+
|
710
|
+
reset();
|
711
|
+
$('#table').append('<caption></caption>');
|
712
|
+
ok( $('#table caption').length, "Append caption" );
|
713
|
+
|
714
|
+
reset();
|
715
|
+
$('form:last')
|
716
|
+
.append('<select id="appendSelect1"></select>')
|
717
|
+
.append('<select id="appendSelect2"><option>Test</option></select>');
|
718
|
+
|
719
|
+
t( "Append Select", "#appendSelect1, #appendSelect2", ["appendSelect1", "appendSelect2"] );
|
720
|
+
|
721
|
+
// using contents will get comments regular, text, and comment nodes
|
722
|
+
var j = $("#nonnodes").contents();
|
723
|
+
var d = $("<div/>").appendTo("#nonnodes").append(j);
|
724
|
+
equals( $("#nonnodes").length, 1, "Check node,textnode,comment append moved leaving just the div" );
|
725
|
+
ok( d.contents().length >= 2, "Check node,textnode,comment append works" );
|
726
|
+
d.contents().appendTo("#nonnodes");
|
727
|
+
d.remove();
|
728
|
+
ok( $("#nonnodes").contents().length >= 2, "Check node,textnode,comment append cleanup worked" );
|
724
729
|
});
|
725
730
|
|
726
731
|
test("appendTo(String|Element|Array<Element>|jQuery)", function() {
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
732
|
+
expect(6);
|
733
|
+
var defaultText = 'Try them out:'
|
734
|
+
$('<b>buga</b>').appendTo('#first');
|
735
|
+
ok( $("#first").text() == defaultText + 'buga', 'Check if text appending works' );
|
736
|
+
ok( $('<option value="appendTest">Append Test</option>').appendTo('#select3').parent().find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');
|
737
|
+
|
738
|
+
reset();
|
739
|
+
var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
|
740
|
+
$(document.getElementById('first')).appendTo('#sap');
|
741
|
+
ok( expected == $('#sap').text(), "Check for appending of element" );
|
742
|
+
|
743
|
+
reset();
|
744
|
+
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
|
745
|
+
$([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap');
|
746
|
+
ok( expected == $('#sap').text(), "Check for appending of array of elements" );
|
747
|
+
|
748
|
+
reset();
|
749
|
+
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
|
750
|
+
$("#first, #yahoo").appendTo('#sap');
|
751
|
+
ok( expected == $('#sap').text(), "Check for appending of jQuery object" );
|
752
|
+
|
753
|
+
reset();
|
754
|
+
$('#select1').appendTo('#foo');
|
755
|
+
t( 'Append select', '#foo select', ['select1'] );
|
751
756
|
});
|
752
757
|
|
753
758
|
test("prepend(String|Element|Array<Element>|jQuery)", function() {
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
759
|
+
expect(5);
|
760
|
+
var defaultText = 'Try them out:'
|
761
|
+
var result = $('#first').prepend('<b>buga</b>');
|
762
|
+
ok( result.text() == 'buga' + defaultText, 'Check if text prepending works' );
|
763
|
+
ok( $('#select3').prepend('<option value="prependTest">Prepend Test</option>').find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');
|
764
|
+
|
765
|
+
reset();
|
766
|
+
var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
|
767
|
+
$('#sap').prepend(document.getElementById('first'));
|
768
|
+
ok( expected == $('#sap').text(), "Check for prepending of element" );
|
769
|
+
|
770
|
+
reset();
|
771
|
+
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
|
772
|
+
$('#sap').prepend([document.getElementById('first'), document.getElementById('yahoo')]);
|
773
|
+
ok( expected == $('#sap').text(), "Check for prepending of array of elements" );
|
774
|
+
|
775
|
+
reset();
|
776
|
+
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
|
777
|
+
$('#sap').prepend($("#first, #yahoo"));
|
778
|
+
ok( expected == $('#sap').text(), "Check for prepending of jQuery object" );
|
774
779
|
});
|
775
780
|
|
776
781
|
test("prependTo(String|Element|Array<Element>|jQuery)", function() {
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
782
|
+
expect(6);
|
783
|
+
var defaultText = 'Try them out:'
|
784
|
+
$('<b>buga</b>').prependTo('#first');
|
785
|
+
ok( $('#first').text() == 'buga' + defaultText, 'Check if text prepending works' );
|
786
|
+
ok( $('<option value="prependTest">Prepend Test</option>').prependTo('#select3').parent().find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');
|
787
|
+
|
788
|
+
reset();
|
789
|
+
var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
|
790
|
+
$(document.getElementById('first')).prependTo('#sap');
|
791
|
+
ok( expected == $('#sap').text(), "Check for prepending of element" );
|
792
|
+
|
793
|
+
reset();
|
794
|
+
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
|
795
|
+
$([document.getElementById('yahoo'), document.getElementById('first')]).prependTo('#sap');
|
796
|
+
ok( expected == $('#sap').text(), "Check for prepending of array of elements" );
|
797
|
+
|
798
|
+
reset();
|
799
|
+
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
|
800
|
+
$("#yahoo, #first").prependTo('#sap');
|
801
|
+
ok( expected == $('#sap').text(), "Check for prepending of jQuery object" );
|
802
|
+
|
803
|
+
reset();
|
804
|
+
$('<select id="prependSelect1"></select>').prependTo('form:last');
|
805
|
+
$('<select id="prependSelect2"><option>Test</option></select>').prependTo('form:last');
|
806
|
+
|
807
|
+
t( "Prepend Select", "#prependSelect1, #prependSelect2", ["prependSelect1", "prependSelect2"] );
|
803
808
|
});
|
804
809
|
|
805
810
|
test("before(String|Element|Array<Element>|jQuery)", function() {
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
811
|
+
expect(4);
|
812
|
+
var expected = 'This is a normal link: bugaYahoo';
|
813
|
+
$('#yahoo').before('<b>buga</b>');
|
814
|
+
ok( expected == $('#en').text(), 'Insert String before' );
|
815
|
+
|
816
|
+
reset();
|
817
|
+
expected = "This is a normal link: Try them out:Yahoo";
|
818
|
+
$('#yahoo').before(document.getElementById('first'));
|
819
|
+
ok( expected == $('#en').text(), "Insert element before" );
|
820
|
+
|
821
|
+
reset();
|
822
|
+
expected = "This is a normal link: Try them out:diveintomarkYahoo";
|
823
|
+
$('#yahoo').before([document.getElementById('first'), document.getElementById('mark')]);
|
824
|
+
ok( expected == $('#en').text(), "Insert array of elements before" );
|
825
|
+
|
826
|
+
reset();
|
827
|
+
expected = "This is a normal link: Try them out:diveintomarkYahoo";
|
828
|
+
$('#yahoo').before($("#first, #mark"));
|
829
|
+
ok( expected == $('#en').text(), "Insert jQuery before" );
|
825
830
|
});
|
826
831
|
|
827
832
|
test("insertBefore(String|Element|Array<Element>|jQuery)", function() {
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
833
|
+
expect(4);
|
834
|
+
var expected = 'This is a normal link: bugaYahoo';
|
835
|
+
$('<b>buga</b>').insertBefore('#yahoo');
|
836
|
+
ok( expected == $('#en').text(), 'Insert String before' );
|
837
|
+
|
838
|
+
reset();
|
839
|
+
expected = "This is a normal link: Try them out:Yahoo";
|
840
|
+
$(document.getElementById('first')).insertBefore('#yahoo');
|
841
|
+
ok( expected == $('#en').text(), "Insert element before" );
|
842
|
+
|
843
|
+
reset();
|
844
|
+
expected = "This is a normal link: Try them out:diveintomarkYahoo";
|
845
|
+
$([document.getElementById('first'), document.getElementById('mark')]).insertBefore('#yahoo');
|
846
|
+
ok( expected == $('#en').text(), "Insert array of elements before" );
|
847
|
+
|
848
|
+
reset();
|
849
|
+
expected = "This is a normal link: Try them out:diveintomarkYahoo";
|
850
|
+
$("#first, #mark").insertBefore('#yahoo');
|
851
|
+
ok( expected == $('#en').text(), "Insert jQuery before" );
|
847
852
|
});
|
848
853
|
|
849
854
|
test("after(String|Element|Array<Element>|jQuery)", function() {
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
855
|
+
expect(4);
|
856
|
+
var expected = 'This is a normal link: Yahoobuga';
|
857
|
+
$('#yahoo').after('<b>buga</b>');
|
858
|
+
ok( expected == $('#en').text(), 'Insert String after' );
|
859
|
+
|
860
|
+
reset();
|
861
|
+
expected = "This is a normal link: YahooTry them out:";
|
862
|
+
$('#yahoo').after(document.getElementById('first'));
|
863
|
+
ok( expected == $('#en').text(), "Insert element after" );
|
864
|
+
|
865
|
+
reset();
|
866
|
+
expected = "This is a normal link: YahooTry them out:diveintomark";
|
867
|
+
$('#yahoo').after([document.getElementById('first'), document.getElementById('mark')]);
|
868
|
+
ok( expected == $('#en').text(), "Insert array of elements after" );
|
869
|
+
|
870
|
+
reset();
|
871
|
+
expected = "This is a normal link: YahooTry them out:diveintomark";
|
872
|
+
$('#yahoo').after($("#first, #mark"));
|
873
|
+
ok( expected == $('#en').text(), "Insert jQuery after" );
|
869
874
|
});
|
870
875
|
|
871
876
|
test("insertAfter(String|Element|Array<Element>|jQuery)", function() {
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
877
|
+
expect(4);
|
878
|
+
var expected = 'This is a normal link: Yahoobuga';
|
879
|
+
$('<b>buga</b>').insertAfter('#yahoo');
|
880
|
+
ok( expected == $('#en').text(), 'Insert String after' );
|
881
|
+
|
882
|
+
reset();
|
883
|
+
expected = "This is a normal link: YahooTry them out:";
|
884
|
+
$(document.getElementById('first')).insertAfter('#yahoo');
|
885
|
+
ok( expected == $('#en').text(), "Insert element after" );
|
886
|
+
|
887
|
+
reset();
|
888
|
+
expected = "This is a normal link: YahooTry them out:diveintomark";
|
889
|
+
$([document.getElementById('mark'), document.getElementById('first')]).insertAfter('#yahoo');
|
890
|
+
ok( expected == $('#en').text(), "Insert array of elements after" );
|
891
|
+
|
892
|
+
reset();
|
893
|
+
expected = "This is a normal link: YahooTry them out:diveintomark";
|
894
|
+
$("#mark, #first").insertAfter('#yahoo');
|
895
|
+
ok( expected == $('#en').text(), "Insert jQuery after" );
|
891
896
|
});
|
892
897
|
|
893
898
|
test("replaceWith(String|Element|Array<Element>|jQuery)", function() {
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
899
|
+
expect(10);
|
900
|
+
$('#yahoo').replaceWith('<b id="replace">buga</b>');
|
901
|
+
ok( $("#replace")[0], 'Replace element with string' );
|
902
|
+
ok( !$("#yahoo")[0], 'Verify that original element is gone, after string' );
|
903
|
+
|
904
|
+
reset();
|
905
|
+
$('#yahoo').replaceWith(document.getElementById('first'));
|
906
|
+
ok( $("#first")[0], 'Replace element with element' );
|
907
|
+
ok( !$("#yahoo")[0], 'Verify that original element is gone, after element' );
|
908
|
+
|
909
|
+
reset();
|
910
|
+
$('#yahoo').replaceWith([document.getElementById('first'), document.getElementById('mark')]);
|
911
|
+
ok( $("#first")[0], 'Replace element with array of elements' );
|
912
|
+
ok( $("#mark")[0], 'Replace element with array of elements' );
|
913
|
+
ok( !$("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
|
914
|
+
|
915
|
+
reset();
|
916
|
+
$('#yahoo').replaceWith($("#first, #mark"));
|
917
|
+
ok( $("#first")[0], 'Replace element with set of elements' );
|
918
|
+
ok( $("#mark")[0], 'Replace element with set of elements' );
|
919
|
+
ok( !$("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
|
915
920
|
});
|
916
921
|
|
917
922
|
test("replaceAll(String|Element|Array<Element>|jQuery)", function() {
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
923
|
+
expect(10);
|
924
|
+
$('<b id="replace">buga</b>').replaceAll("#yahoo");
|
925
|
+
ok( $("#replace")[0], 'Replace element with string' );
|
926
|
+
ok( !$("#yahoo")[0], 'Verify that original element is gone, after string' );
|
927
|
+
|
928
|
+
reset();
|
929
|
+
$(document.getElementById('first')).replaceAll("#yahoo");
|
930
|
+
ok( $("#first")[0], 'Replace element with element' );
|
931
|
+
ok( !$("#yahoo")[0], 'Verify that original element is gone, after element' );
|
932
|
+
|
933
|
+
reset();
|
934
|
+
$([document.getElementById('first'), document.getElementById('mark')]).replaceAll("#yahoo");
|
935
|
+
ok( $("#first")[0], 'Replace element with array of elements' );
|
936
|
+
ok( $("#mark")[0], 'Replace element with array of elements' );
|
937
|
+
ok( !$("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
|
938
|
+
|
939
|
+
reset();
|
940
|
+
$("#first, #mark").replaceAll("#yahoo");
|
941
|
+
ok( $("#first")[0], 'Replace element with set of elements' );
|
942
|
+
ok( $("#mark")[0], 'Replace element with set of elements' );
|
943
|
+
ok( !$("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
|
939
944
|
});
|
940
945
|
|
941
946
|
test("end()", function() {
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
947
|
+
expect(3);
|
948
|
+
ok( 'Yahoo' == $('#yahoo').parent().end().text(), 'Check for end' );
|
949
|
+
ok( $('#yahoo').end(), 'Check for end with nothing to end' );
|
950
|
+
|
951
|
+
var x = $('#yahoo');
|
952
|
+
x.parent();
|
953
|
+
ok( 'Yahoo' == $('#yahoo').text(), 'Check for non-destructive behaviour' );
|
949
954
|
});
|
950
955
|
|
951
956
|
test("find(String)", function() {
|
952
|
-
|
953
|
-
|
957
|
+
expect(2);
|
958
|
+
ok( 'Yahoo' == $('#foo').find('.blogTest').text(), 'Check for find' );
|
954
959
|
|
955
|
-
|
956
|
-
|
957
|
-
|
960
|
+
// using contents will get comments regular, text, and comment nodes
|
961
|
+
var j = $("#nonnodes").contents();
|
962
|
+
equals( j.find("div").length, 0, "Check node,textnode,comment to find zero divs" );
|
958
963
|
});
|
959
964
|
|
960
965
|
test("clone()", function() {
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
966
|
+
expect(20);
|
967
|
+
ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Assert text for #en' );
|
968
|
+
var clone = $('#yahoo').clone();
|
969
|
+
ok( 'Try them out:Yahoo' == $('#first').append(clone).text(), 'Check for clone' );
|
970
|
+
ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Reassert text for #en' );
|
971
|
+
|
972
|
+
var cloneTags = [
|
973
|
+
"<table/>", "<tr/>", "<td/>", "<div/>",
|
974
|
+
"<button/>", "<ul/>", "<ol/>", "<li/>",
|
975
|
+
"<input type='checkbox' />", "<select/>", "<option/>", "<textarea/>",
|
976
|
+
"<tbody/>", "<thead/>", "<tfoot/>", "<iframe/>"
|
977
|
+
];
|
978
|
+
for (var i = 0; i < cloneTags.length; i++) {
|
979
|
+
var j = $(cloneTags[i]);
|
980
|
+
equals( j[0].tagName, j.clone()[0].tagName, 'Clone a <' + cloneTags[i].substring(1));
|
981
|
+
}
|
982
|
+
|
983
|
+
// using contents will get comments regular, text, and comment nodes
|
984
|
+
var cl = $("#nonnodes").contents().clone();
|
985
|
+
ok( cl.length >= 2, "Check node,textnode,comment clone works (some browsers delete comments on clone)" );
|
981
986
|
});
|
982
987
|
|
983
988
|
if (!isLocal) {
|
984
989
|
test("clone() on XML nodes", function() {
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
990
|
+
expect(2);
|
991
|
+
stop();
|
992
|
+
$.get("data/dashboard.xml", function (xml) {
|
993
|
+
var root = $(xml.documentElement).clone();
|
994
|
+
$("tab:first", xml).text("origval");
|
995
|
+
$("tab:first", root).text("cloneval");
|
996
|
+
equals($("tab:first", xml).text(), "origval", "Check original XML node was correctly set");
|
997
|
+
equals($("tab:first", root).text(), "cloneval", "Check cloned XML node was correctly set");
|
998
|
+
start();
|
999
|
+
});
|
995
1000
|
});
|
996
1001
|
}
|
997
1002
|
|
998
1003
|
test("is(String)", function() {
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1004
|
+
expect(26);
|
1005
|
+
ok( $('#form').is('form'), 'Check for element: A form must be a form' );
|
1006
|
+
ok( !$('#form').is('div'), 'Check for element: A form is not a div' );
|
1007
|
+
ok( $('#mark').is('.blog'), 'Check for class: Expected class "blog"' );
|
1008
|
+
ok( !$('#mark').is('.link'), 'Check for class: Did not expect class "link"' );
|
1009
|
+
ok( $('#simon').is('.blog.link'), 'Check for multiple classes: Expected classes "blog" and "link"' );
|
1010
|
+
ok( !$('#simon').is('.blogTest'), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' );
|
1011
|
+
ok( $('#en').is('[lang="en"]'), 'Check for attribute: Expected attribute lang to be "en"' );
|
1012
|
+
ok( !$('#en').is('[lang="de"]'), 'Check for attribute: Expected attribute lang to be "en", not "de"' );
|
1013
|
+
ok( $('#text1').is('[type="text"]'), 'Check for attribute: Expected attribute type to be "text"' );
|
1014
|
+
ok( !$('#text1').is('[type="radio"]'), 'Check for attribute: Expected attribute type to be "text", not "radio"' );
|
1015
|
+
ok( $('#text2').is(':disabled'), 'Check for pseudoclass: Expected to be disabled' );
|
1016
|
+
ok( !$('#text1').is(':disabled'), 'Check for pseudoclass: Expected not disabled' );
|
1017
|
+
ok( $('#radio2').is(':checked'), 'Check for pseudoclass: Expected to be checked' );
|
1018
|
+
ok( !$('#radio1').is(':checked'), 'Check for pseudoclass: Expected not checked' );
|
1019
|
+
ok( $('#foo').is(':has(p)'), 'Check for child: Expected a child "p" element' );
|
1020
|
+
ok( !$('#foo').is(':has(ul)'), 'Check for child: Did not expect "ul" element' );
|
1021
|
+
ok( $('#foo').is(':has(p):has(a):has(code)'), 'Check for childs: Expected "p", "a" and "code" child elements' );
|
1022
|
+
ok( !$('#foo').is(':has(p):has(a):has(code):has(ol)'), 'Check for childs: Expected "p", "a" and "code" child elements, but no "ol"' );
|
1023
|
+
ok( !$('#foo').is(0), 'Expected false for an invalid expression - 0' );
|
1024
|
+
ok( !$('#foo').is(null), 'Expected false for an invalid expression - null' );
|
1025
|
+
ok( !$('#foo').is(''), 'Expected false for an invalid expression - ""' );
|
1026
|
+
ok( !$('#foo').is(undefined), 'Expected false for an invalid expression - undefined' );
|
1027
|
+
|
1028
|
+
// test is() with comma-seperated expressions
|
1029
|
+
ok( $('#en').is('[lang="en"],[lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
|
1030
|
+
ok( $('#en').is('[lang="de"],[lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
|
1031
|
+
ok( $('#en').is('[lang="en"] , [lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
|
1032
|
+
ok( $('#en').is('[lang="de"] , [lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
|
1028
1033
|
});
|
1029
1034
|
|
1030
1035
|
test("$.extend(Object, Object)", function() {
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1036
|
+
expect(17);
|
1037
|
+
|
1038
|
+
var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
|
1039
|
+
options = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
|
1040
|
+
optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
|
1041
|
+
merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" },
|
1042
|
+
deep1 = { foo: { bar: true } },
|
1043
|
+
deep1copy = { foo: { bar: true } },
|
1044
|
+
deep2 = { foo: { baz: true }, foo2: document },
|
1045
|
+
deep2copy = { foo: { baz: true }, foo2: document },
|
1046
|
+
deepmerged = { foo: { bar: true, baz: true }, foo2: document };
|
1047
|
+
|
1048
|
+
jQuery.extend(settings, options);
|
1049
|
+
isObj( settings, merged, "Check if extended: settings must be extended" );
|
1050
|
+
isObj( options, optionsCopy, "Check if not modified: options must not be modified" );
|
1051
|
+
|
1052
|
+
jQuery.extend(settings, null, options);
|
1053
|
+
isObj( settings, merged, "Check if extended: settings must be extended" );
|
1054
|
+
isObj( options, optionsCopy, "Check if not modified: options must not be modified" );
|
1055
|
+
|
1056
|
+
jQuery.extend(true, deep1, deep2);
|
1057
|
+
isObj( deep1.foo, deepmerged.foo, "Check if foo: settings must be extended" );
|
1058
|
+
isObj( deep2.foo, deep2copy.foo, "Check if not deep2: options must not be modified" );
|
1059
|
+
equals( deep1.foo2, document, "Make sure that a deep clone was not attempted on the document" );
|
1060
|
+
|
1061
|
+
var target = {};
|
1062
|
+
var recursive = { foo:target, bar:5 };
|
1063
|
+
jQuery.extend(true, target, recursive);
|
1064
|
+
isObj( target, { bar:5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" );
|
1065
|
+
|
1066
|
+
var ret = jQuery.extend(true, { foo: [] }, { foo: [0] } ); // 1907
|
1067
|
+
ok( ret.foo.length == 1, "Check to make sure a value with coersion 'false' copies over when necessary to fix #1907" );
|
1068
|
+
|
1069
|
+
var ret = jQuery.extend(true, { foo: "1,2,3" }, { foo: [1, 2, 3] } );
|
1070
|
+
ok( typeof ret.foo != "string", "Check to make sure values equal with coersion (but not actually equal) overwrite correctly" );
|
1071
|
+
|
1072
|
+
var ret = jQuery.extend(true, { foo:"bar" }, { foo:null } );
|
1073
|
+
ok( typeof ret.foo !== 'undefined', "Make sure a null value doesn't crash with deep extend, for #1908" );
|
1074
|
+
|
1075
|
+
var obj = { foo:null };
|
1076
|
+
jQuery.extend(true, obj, { foo:"notnull" } );
|
1077
|
+
equals( obj.foo, "notnull", "Make sure a null value can be overwritten" );
|
1078
|
+
|
1079
|
+
function func() {}
|
1080
|
+
jQuery.extend(func, { key: "value" } );
|
1081
|
+
equals( func.key, "value", "Verify a function can be extended" );
|
1082
|
+
|
1083
|
+
var defaults = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
|
1084
|
+
defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
|
1085
|
+
options1 = { xnumber2: 1, xstring2: "x" },
|
1086
|
+
options1Copy = { xnumber2: 1, xstring2: "x" },
|
1087
|
+
options2 = { xstring2: "xx", xxx: "newstringx" },
|
1088
|
+
options2Copy = { xstring2: "xx", xxx: "newstringx" },
|
1089
|
+
merged2 = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "xx", xxx: "newstringx" };
|
1090
|
+
|
1091
|
+
var settings = jQuery.extend({}, defaults, options1, options2);
|
1092
|
+
isObj( settings, merged2, "Check if extended: settings must be extended" );
|
1093
|
+
isObj( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" );
|
1094
|
+
isObj( options1, options1Copy, "Check if not modified: options1 must not be modified" );
|
1095
|
+
isObj( options2, options2Copy, "Check if not modified: options2 must not be modified" );
|
1091
1096
|
});
|
1092
1097
|
|
1093
1098
|
test("val()", function() {
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1099
|
+
expect(4);
|
1100
|
+
ok( $("#text1").val() == "Test", "Check for value of input element" );
|
1101
|
+
ok( !$("#text1").val() == "", "Check for value of input element" );
|
1102
|
+
// ticket #1714 this caused a JS error in IE
|
1103
|
+
ok( $("#first").val() == "", "Check a paragraph element to see if it has a value" );
|
1104
|
+
ok( $([]).val() === undefined, "Check an empty jQuery object will return undefined from val" );
|
1100
1105
|
});
|
1101
1106
|
|
1102
1107
|
// test("val(String)", function() {
|
@@ -1119,238 +1124,238 @@ test("val()", function() {
|
|
1119
1124
|
var scriptorder = 0;
|
1120
1125
|
|
1121
1126
|
test("html(String)", function() {
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1127
|
+
expect(11);
|
1128
|
+
var div = $("#main > div");
|
1129
|
+
div.html("<b>test</b>");
|
1130
|
+
var pass = true;
|
1131
|
+
for ( var i = 0; i < div.size(); i++ ) {
|
1132
|
+
if ( div.get(i).childNodes.length != 1 ) pass = false;
|
1133
|
+
}
|
1134
|
+
ok( pass, "Set HTML" );
|
1130
1135
|
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
+
reset();
|
1137
|
+
// using contents will get comments regular, text, and comment nodes
|
1138
|
+
var j = $("#nonnodes").contents();
|
1139
|
+
j.html("<b>bold</b>");
|
1140
|
+
equals( j.html().toLowerCase(), "<b>bold</b>", "Check node,textnode,comment with html()" );
|
1136
1141
|
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1142
|
+
$("#main").html("<select/>");
|
1143
|
+
$("#main select").html("<option>O1</option><option selected='selected'>O2</option><option>O3</option>");
|
1144
|
+
equals( $("#main select").val(), "O2", "Selected option correct" );
|
1140
1145
|
|
1141
|
-
|
1146
|
+
stop();
|
1142
1147
|
|
1143
|
-
|
1148
|
+
$("#main").html('<script type="text/javascript">ok( true, "$().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script>');
|
1144
1149
|
|
1145
|
-
|
1150
|
+
$("#main").html('foo <form><script type="text/javascript">ok( true, "$().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script></form>');
|
1146
1151
|
|
1147
|
-
|
1148
|
-
|
1152
|
+
// it was decided that waiting to execute ALL scripts makes sense since nested ones have to wait anyway so this test case is changed, see #1959
|
1153
|
+
$("#main").html("<script>ok(scriptorder++ == 0, 'Script is executed in order');ok($('#scriptorder').length == 1,'Execute after html (even though appears before)')<\/script><span id='scriptorder'><script>ok(scriptorder++ == 1, 'Script (nested) is executed in order');ok($('#scriptorder').length == 1,'Execute after html')<\/script></span><script>ok(scriptorder++ == 2, 'Script (unnested) is executed in order');ok($('#scriptorder').length == 1,'Execute after html')<\/script>");
|
1149
1154
|
|
1150
|
-
|
1155
|
+
setTimeout( start, 100 );
|
1151
1156
|
});
|
1152
1157
|
|
1153
1158
|
test("filter()", function() {
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
+
expect(6);
|
1160
|
+
isSet( $("#form input").filter(":checked").get(), q("radio2", "check1"), "filter(String)" );
|
1161
|
+
isSet( $("p").filter("#ap, #sndp").get(), q("ap", "sndp"), "filter('String, String')" );
|
1162
|
+
isSet( $("p").filter("#ap,#sndp").get(), q("ap", "sndp"), "filter('String,String')" );
|
1163
|
+
isSet( $("p").filter(function() { return !$("a", this).length }).get(), q("sndp", "first"), "filter(Function)" );
|
1159
1164
|
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1165
|
+
// using contents will get comments regular, text, and comment nodes
|
1166
|
+
var j = $("#nonnodes").contents();
|
1167
|
+
equals( j.filter("span").length, 1, "Check node,textnode,comment to filter the one span" );
|
1168
|
+
equals( j.filter("[name]").length, 0, "Check node,textnode,comment to filter the one span" );
|
1164
1169
|
});
|
1165
1170
|
|
1166
1171
|
test("not()", function() {
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1172
|
+
expect(8);
|
1173
|
+
ok( $("#main > p#ap > a").not("#google").length == 2, "not('selector')" );
|
1174
|
+
ok( $("#main > p#ap > a").not(document.getElementById("google")).length == 2, "not(DOMElement)" );
|
1175
|
+
isSet( $("p").not(".result").get(), q("firstp", "ap", "sndp", "en", "sap", "first"), "not('.class')" );
|
1176
|
+
isSet( $("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" );
|
1177
|
+
isSet( $("p").not($("#ap, #sndp, .result")).get(), q("firstp", "en", "sap", "first"), "not(jQuery)" );
|
1178
|
+
ok( $("p").not(document.getElementsByTagName("p")).length == 0, "not(Array-like DOM collection)" );
|
1179
|
+
isSet( $("#form option").not("option.emptyopt:contains('Nothing'),[selected],[value='1']").get(), q("option1c", "option1d", "option2c", "option3d" ), "not('complex selector')");
|
1180
|
+
|
1181
|
+
var selects = $("#form select");
|
1182
|
+
isSet( selects.not( selects[1] ), q("select1", "select3"), "filter out DOM element");
|
1178
1183
|
});
|
1179
1184
|
|
1180
1185
|
test("andSelf()", function() {
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
+
expect(4);
|
1187
|
+
isSet( $("#en").siblings().andSelf().get(), q("sndp", "sap","en"), "Check for siblings and self" );
|
1188
|
+
isSet( $("#foo").children().andSelf().get(), q("sndp", "en", "sap", "foo"), "Check for children and self" );
|
1189
|
+
isSet( $("#en, #sndp").parent().andSelf().get(), q("foo","en","sndp"), "Check for parent and self" );
|
1190
|
+
isSet( $("#groups").parents("p, div").andSelf().get(), q("ap", "main", "groups"), "Check for parents and self" );
|
1186
1191
|
});
|
1187
1192
|
|
1188
1193
|
test("siblings([String])", function() {
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1194
|
+
expect(5);
|
1195
|
+
isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" );
|
1196
|
+
isSet( $("#sndp").siblings(":has(code)").get(), q("sap"), "Check for filtered siblings (has code child element)" );
|
1197
|
+
isSet( $("#sndp").siblings(":has(a)").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" );
|
1198
|
+
isSet( $("#foo").siblings("form, b").get(), q("form", "lengthtest", "testForm", "floatTest"), "Check for multiple filters" );
|
1199
|
+
isSet( $("#en, #sndp").siblings().get(), q("sndp", "sap", "en"), "Check for unique results from siblings" );
|
1195
1200
|
});
|
1196
1201
|
|
1197
1202
|
test("children([String])", function() {
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1203
|
+
expect(3);
|
1204
|
+
isSet( $("#foo").children().get(), q("sndp", "en", "sap"), "Check for children" );
|
1205
|
+
isSet( $("#foo").children(":has(code)").get(), q("sndp", "sap"), "Check for filtered children" );
|
1206
|
+
isSet( $("#foo").children("#en, #sap").get(), q("en", "sap"), "Check for multiple filters" );
|
1202
1207
|
});
|
1203
1208
|
|
1204
1209
|
test("parent([String])", function() {
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
});
|
1212
|
-
|
1210
|
+
expect(5);
|
1211
|
+
ok( $("#groups").parent()[0].id == "ap", "Simple parent check" );
|
1212
|
+
ok( $("#groups").parent("p")[0].id == "ap", "Filtered parent check" );
|
1213
|
+
ok( $("#groups").parent("div").length == 0, "Filtered parent check, no match" );
|
1214
|
+
ok( $("#groups").parent("div, p")[0].id == "ap", "Check for multiple filters" );
|
1215
|
+
isSet( $("#en, #sndp").parent().get(), q("foo"), "Check for unique results from parent" );
|
1216
|
+
});
|
1217
|
+
|
1213
1218
|
test("parents([String])", function() {
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1219
|
+
expect(5);
|
1220
|
+
ok( $("#groups").parents()[0].id == "ap", "Simple parents check" );
|
1221
|
+
ok( $("#groups").parents("p")[0].id == "ap", "Filtered parents check" );
|
1222
|
+
ok( $("#groups").parents("div")[0].id == "main", "Filtered parents check2" );
|
1223
|
+
isSet( $("#groups").parents("p, div").get(), q("ap", "main"), "Check for multiple filters" );
|
1224
|
+
isSet( $("#en, #sndp").parents().get(), q("foo", "main", "dl", "body", "html"), "Check for unique results from parents" );
|
1220
1225
|
});
|
1221
1226
|
|
1222
1227
|
test("next([String])", function() {
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
+
expect(4);
|
1229
|
+
ok( $("#ap").next()[0].id == "foo", "Simple next check" );
|
1230
|
+
ok( $("#ap").next("div")[0].id == "foo", "Filtered next check" );
|
1231
|
+
ok( $("#ap").next("p").length == 0, "Filtered next check, no match" );
|
1232
|
+
ok( $("#ap").next("div, p")[0].id == "foo", "Multiple filters" );
|
1228
1233
|
});
|
1229
|
-
|
1234
|
+
|
1230
1235
|
test("prev([String])", function() {
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
+
expect(4);
|
1237
|
+
ok( $("#foo").prev()[0].id == "ap", "Simple prev check" );
|
1238
|
+
ok( $("#foo").prev("p")[0].id == "ap", "Filtered prev check" );
|
1239
|
+
ok( $("#foo").prev("div").length == 0, "Filtered prev check, no match" );
|
1240
|
+
ok( $("#foo").prev("p, div")[0].id == "ap", "Multiple filters" );
|
1236
1241
|
});
|
1237
1242
|
|
1238
1243
|
test("show()", function() {
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1244
|
+
expect(15);
|
1245
|
+
var pass = true, div = $("div");
|
1246
|
+
div.show().each(function(){
|
1247
|
+
if ( this.style.display == "none" ) pass = false;
|
1248
|
+
});
|
1249
|
+
ok( pass, "Show" );
|
1250
|
+
|
1251
|
+
$("#main").append('<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div>');
|
1252
|
+
var test = {
|
1253
|
+
"div" : "block",
|
1254
|
+
"p" : "block",
|
1255
|
+
"a" : "inline",
|
1256
|
+
"code" : "inline",
|
1257
|
+
"pre" : "block",
|
1258
|
+
"span" : "inline",
|
1259
|
+
"table" : $.browser.msie ? "block" : "table",
|
1260
|
+
"thead" : $.browser.msie ? "block" : "table-header-group",
|
1261
|
+
"tbody" : $.browser.msie ? "block" : "table-row-group",
|
1262
|
+
"tr" : $.browser.msie ? "block" : "table-row",
|
1263
|
+
"th" : $.browser.msie ? "block" : "table-cell",
|
1264
|
+
"td" : $.browser.msie ? "block" : "table-cell",
|
1265
|
+
"ul" : "block",
|
1266
|
+
"li" : $.browser.msie ? "block" : "list-item"
|
1267
|
+
};
|
1268
|
+
|
1269
|
+
$.each(test, function(selector, expected) {
|
1270
|
+
var elem = $(selector, "#show-tests").show();
|
1271
|
+
equals( elem.css("display"), expected, "Show using correct display type for " + selector );
|
1272
|
+
});
|
1268
1273
|
});
|
1269
1274
|
|
1270
1275
|
test("addClass(String)", function() {
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1276
|
+
expect(2);
|
1277
|
+
var div = $("div");
|
1278
|
+
div.addClass("test");
|
1279
|
+
var pass = true;
|
1280
|
+
for ( var i = 0; i < div.size(); i++ ) {
|
1281
|
+
if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
|
1282
|
+
}
|
1283
|
+
ok( pass, "Add Class" );
|
1279
1284
|
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1285
|
+
// using contents will get regular, text, and comment nodes
|
1286
|
+
var j = $("#nonnodes").contents();
|
1287
|
+
j.addClass("asdf");
|
1288
|
+
ok( j.hasClass("asdf"), "Check node,textnode,comment for addClass" );
|
1284
1289
|
});
|
1285
1290
|
|
1286
1291
|
test("removeClass(String) - simple", function() {
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1292
|
+
expect(4);
|
1293
|
+
var div = $("div").addClass("test").removeClass("test"),
|
1294
|
+
pass = true;
|
1295
|
+
for ( var i = 0; i < div.size(); i++ ) {
|
1296
|
+
if ( div.get(i).className.indexOf("test") != -1 ) pass = false;
|
1297
|
+
}
|
1298
|
+
ok( pass, "Remove Class" );
|
1299
|
+
|
1300
|
+
reset();
|
1301
|
+
var div = $("div").addClass("test").addClass("foo").addClass("bar");
|
1302
|
+
div.removeClass("test").removeClass("bar").removeClass("foo");
|
1303
|
+
var pass = true;
|
1304
|
+
for ( var i = 0; i < div.size(); i++ ) {
|
1305
|
+
if ( div.get(i).className.match(/test|bar|foo/) ) pass = false;
|
1306
|
+
}
|
1307
|
+
ok( pass, "Remove multiple classes" );
|
1308
|
+
|
1309
|
+
reset();
|
1310
|
+
var div = $("div:eq(0)").addClass("test").removeClass("");
|
1311
|
+
ok( div.is('.test'), "Empty string passed to removeClass" );
|
1312
|
+
|
1313
|
+
// using contents will get regular, text, and comment nodes
|
1314
|
+
var j = $("#nonnodes").contents();
|
1315
|
+
j.removeClass("asdf");
|
1316
|
+
ok( !j.hasClass("asdf"), "Check node,textnode,comment for removeClass" );
|
1312
1317
|
});
|
1313
1318
|
|
1314
1319
|
test("toggleClass(String)", function() {
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1320
|
+
expect(3);
|
1321
|
+
var e = $("#firstp");
|
1322
|
+
ok( !e.is(".test"), "Assert class not present" );
|
1323
|
+
e.toggleClass("test");
|
1324
|
+
ok( e.is(".test"), "Assert class present" );
|
1325
|
+
e.toggleClass("test");
|
1326
|
+
ok( !e.is(".test"), "Assert class not present" );
|
1322
1327
|
});
|
1323
1328
|
|
1324
1329
|
test("removeAttr(String", function() {
|
1325
|
-
|
1326
|
-
|
1330
|
+
expect(1);
|
1331
|
+
ok( $('#mark').removeAttr("class")[0].className == "", "remove class" );
|
1327
1332
|
});
|
1328
1333
|
|
1329
1334
|
test("text(String)", function() {
|
1330
|
-
|
1331
|
-
|
1335
|
+
expect(4);
|
1336
|
+
ok( $("#foo").text("<div><b>Hello</b> cruel world!</div>")[0].innerHTML == "<div><b>Hello</b> cruel world!</div>", "Check escaped text" );
|
1332
1337
|
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1338
|
+
// using contents will get comments regular, text, and comment nodes
|
1339
|
+
var j = $("#nonnodes").contents();
|
1340
|
+
j.text("hi!");
|
1341
|
+
equals( $(j[0]).text(), "hi!", "Check node,textnode,comment with text()" );
|
1342
|
+
equals( j[1].nodeValue, " there ", "Check node,textnode,comment with text()" );
|
1343
|
+
equals( j[2].nodeType, 8, "Check node,textnode,comment with text()" );
|
1339
1344
|
});
|
1340
1345
|
|
1341
1346
|
test("$.each(Object,Function)", function() {
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1347
|
+
expect(12);
|
1348
|
+
$.each( [0,1,2], function(i, n){
|
1349
|
+
ok( i == n, "Check array iteration" );
|
1350
|
+
});
|
1351
|
+
|
1352
|
+
$.each( [5,6,7], function(i, n){
|
1353
|
+
ok( i == n - 5, "Check array iteration" );
|
1354
|
+
});
|
1355
|
+
|
1356
|
+
$.each( { name: "name", lang: "lang" }, function(i, n){
|
1357
|
+
ok( i == n, "Check object iteration" );
|
1358
|
+
});
|
1354
1359
|
|
1355
1360
|
var total = 0;
|
1356
1361
|
jQuery.each([1,2,3], function(i,v){ total += v; });
|
@@ -1367,200 +1372,200 @@ test("$.each(Object,Function)", function() {
|
|
1367
1372
|
});
|
1368
1373
|
|
1369
1374
|
test("$.prop", function() {
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1375
|
+
expect(2);
|
1376
|
+
var handle = function() { return this.id };
|
1377
|
+
ok( $.prop($("#ap")[0], handle) == "ap", "Check with Function argument" );
|
1378
|
+
ok( $.prop($("#ap")[0], "value") == "value", "Check with value argument" );
|
1374
1379
|
});
|
1375
1380
|
|
1376
1381
|
test("$.className", function() {
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1382
|
+
expect(6);
|
1383
|
+
var x = $("<p>Hi</p>")[0];
|
1384
|
+
var c = $.className;
|
1385
|
+
c.add(x, "hi");
|
1386
|
+
ok( x.className == "hi", "Check single added class" );
|
1387
|
+
c.add(x, "foo bar");
|
1388
|
+
ok( x.className == "hi foo bar", "Check more added classes" );
|
1389
|
+
c.remove(x);
|
1390
|
+
ok( x.className == "", "Remove all classes" );
|
1391
|
+
c.add(x, "hi foo bar");
|
1392
|
+
c.remove(x, "foo");
|
1393
|
+
ok( x.className == "hi bar", "Check removal of one class" );
|
1394
|
+
ok( c.has(x, "hi"), "Check has1" );
|
1395
|
+
ok( c.has(x, "bar"), "Check has2" );
|
1391
1396
|
});
|
1392
1397
|
|
1393
1398
|
test("$.data", function() {
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1399
|
+
expect(3);
|
1400
|
+
var div = $("#foo")[0];
|
1401
|
+
ok( jQuery.data(div, "test") == undefined, "Check for no data exists" );
|
1402
|
+
jQuery.data(div, "test", "success");
|
1403
|
+
ok( jQuery.data(div, "test") == "success", "Check for added data" );
|
1404
|
+
jQuery.data(div, "test", "overwritten");
|
1405
|
+
ok( jQuery.data(div, "test") == "overwritten", "Check for overwritten data" );
|
1401
1406
|
});
|
1402
1407
|
|
1403
1408
|
test(".data()", function() {
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1409
|
+
expect(16);
|
1410
|
+
var div = $("#foo");
|
1411
|
+
ok( div.data("test") == undefined, "Check for no data exists" );
|
1412
|
+
div.data("test", "success");
|
1413
|
+
ok( div.data("test") == "success", "Check for added data" );
|
1414
|
+
div.data("test", "overwritten");
|
1415
|
+
ok( div.data("test") == "overwritten", "Check for overwritten data" );
|
1416
|
+
|
1417
|
+
var hits = {test:0}, gets = {test:0};
|
1418
|
+
|
1419
|
+
div
|
1420
|
+
.bind("setData",function(e,key,value){ hits[key] += value; })
|
1421
|
+
.bind("setData.foo",function(e,key,value){ hits[key] += value; })
|
1422
|
+
.bind("getData",function(e,key){ gets[key] += 1; })
|
1423
|
+
.bind("getData.foo",function(e,key){ gets[key] += 3; });
|
1424
|
+
|
1425
|
+
div.data("test.foo", 2);
|
1426
|
+
ok( div.data("test") == "overwritten", "Check for original data" );
|
1427
|
+
ok( div.data("test.foo") == 2, "Check for namespaced data" );
|
1428
|
+
ok( div.data("test.bar") == "overwritten", "Check for unmatched namespace" );
|
1429
|
+
equals( hits.test, 2, "Check triggered setter functions" );
|
1430
|
+
equals( gets.test, 5, "Check triggered getter functions" );
|
1431
|
+
|
1432
|
+
hits.test = 0;
|
1433
|
+
gets.test = 0;
|
1434
|
+
|
1435
|
+
div.data("test", 1);
|
1436
|
+
ok( div.data("test") == 1, "Check for original data" );
|
1437
|
+
ok( div.data("test.foo") == 2, "Check for namespaced data" );
|
1438
|
+
ok( div.data("test.bar") == 1, "Check for unmatched namespace" );
|
1439
|
+
equals( hits.test, 1, "Check triggered setter functions" );
|
1440
|
+
equals( gets.test, 5, "Check triggered getter functions" );
|
1441
|
+
|
1442
|
+
hits.test = 0;
|
1443
|
+
gets.test = 0;
|
1444
|
+
|
1445
|
+
div
|
1446
|
+
.bind("getData",function(e,key){ return key + "root"; })
|
1447
|
+
.bind("getData.foo",function(e,key){ return key + "foo"; });
|
1448
|
+
|
1449
|
+
ok( div.data("test") == "testroot", "Check for original data" );
|
1450
|
+
ok( div.data("test.foo") == "testfoo", "Check for namespaced data" );
|
1451
|
+
ok( div.data("test.bar") == "testroot", "Check for unmatched namespace" );
|
1447
1452
|
});
|
1448
1453
|
|
1449
1454
|
test("$.removeData", function() {
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
+
expect(1);
|
1456
|
+
var div = $("#foo")[0];
|
1457
|
+
jQuery.data(div, "test", "testing");
|
1458
|
+
jQuery.removeData(div, "test");
|
1459
|
+
ok( jQuery.data(div, "test") == undefined, "Check removal of data" );
|
1455
1460
|
});
|
1456
1461
|
|
1457
1462
|
test(".removeData()", function() {
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
+
expect(6);
|
1464
|
+
var div = $("#foo");
|
1465
|
+
div.data("test", "testing");
|
1466
|
+
div.removeData("test");
|
1467
|
+
ok( div.data("test") == undefined, "Check removal of data" );
|
1463
1468
|
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
+
div.data("test", "testing");
|
1470
|
+
div.data("test.foo", "testing2");
|
1471
|
+
div.removeData("test.bar");
|
1472
|
+
ok( div.data("test.foo") == "testing2", "Make sure data is intact" );
|
1473
|
+
ok( div.data("test") == "testing", "Make sure data is intact" );
|
1469
1474
|
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1475
|
+
div.removeData("test");
|
1476
|
+
ok( div.data("test.foo") == "testing2", "Make sure data is intact" );
|
1477
|
+
ok( div.data("test") == undefined, "Make sure data is intact" );
|
1473
1478
|
|
1474
|
-
|
1475
|
-
|
1479
|
+
div.removeData("test.foo");
|
1480
|
+
ok( div.data("test.foo") == undefined, "Make sure data is intact" );
|
1476
1481
|
});
|
1477
1482
|
|
1478
1483
|
test("remove()", function() {
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1484
|
+
expect(6);
|
1485
|
+
$("#ap").children().remove();
|
1486
|
+
ok( $("#ap").text().length > 10, "Check text is not removed" );
|
1487
|
+
ok( $("#ap").children().length == 0, "Check remove" );
|
1488
|
+
|
1489
|
+
reset();
|
1490
|
+
$("#ap").children().remove("a");
|
1491
|
+
ok( $("#ap").text().length > 10, "Check text is not removed" );
|
1492
|
+
ok( $("#ap").children().length == 1, "Check filtered remove" );
|
1493
|
+
|
1494
|
+
// using contents will get comments regular, text, and comment nodes
|
1495
|
+
equals( $("#nonnodes").contents().length, 3, "Check node,textnode,comment remove works" );
|
1496
|
+
$("#nonnodes").contents().remove();
|
1497
|
+
equals( $("#nonnodes").contents().length, 0, "Check node,textnode,comment remove works" );
|
1493
1498
|
});
|
1494
1499
|
|
1495
1500
|
test("empty()", function() {
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1501
|
+
expect(3);
|
1502
|
+
ok( $("#ap").children().empty().text().length == 0, "Check text is removed" );
|
1503
|
+
ok( $("#ap").children().length == 4, "Check elements are not removed" );
|
1499
1504
|
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1505
|
+
// using contents will get comments regular, text, and comment nodes
|
1506
|
+
var j = $("#nonnodes").contents();
|
1507
|
+
j.empty();
|
1508
|
+
equals( j.html(), "", "Check node,textnode,comment empty works" );
|
1504
1509
|
});
|
1505
1510
|
|
1506
1511
|
test("slice()", function() {
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
+
expect(5);
|
1513
|
+
isSet( $("#ap a").slice(1,2), q("groups"), "slice(1,2)" );
|
1514
|
+
isSet( $("#ap a").slice(1), q("groups", "anchor1", "mark"), "slice(1)" );
|
1515
|
+
isSet( $("#ap a").slice(0,3), q("google", "groups", "anchor1"), "slice(0,3)" );
|
1516
|
+
isSet( $("#ap a").slice(-1), q("mark"), "slice(-1)" );
|
1512
1517
|
|
1513
|
-
|
1518
|
+
isSet( $("#ap a").eq(1), q("groups"), "eq(1)" );
|
1514
1519
|
});
|
1515
1520
|
|
1516
1521
|
test("map()", function() {
|
1517
|
-
|
1522
|
+
expect(2);
|
1518
1523
|
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1524
|
+
isSet(
|
1525
|
+
$("#ap").map(function(){
|
1526
|
+
return $(this).find("a").get();
|
1527
|
+
}),
|
1528
|
+
q("google", "groups", "anchor1", "mark"),
|
1529
|
+
"Array Map"
|
1530
|
+
);
|
1526
1531
|
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1532
|
+
isSet(
|
1533
|
+
$("#ap > a").map(function(){
|
1534
|
+
return this.parentNode;
|
1535
|
+
}),
|
1536
|
+
q("ap","ap","ap"),
|
1537
|
+
"Single Map"
|
1538
|
+
);
|
1534
1539
|
});
|
1535
1540
|
|
1536
1541
|
test("contents()", function() {
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
+
expect(12);
|
1543
|
+
equals( $("#ap").contents().length, 9, "Check element contents" );
|
1544
|
+
ok( $("#iframe").contents()[0], "Check existance of IFrame document" );
|
1545
|
+
var ibody = $("#loadediframe").contents()[0].body;
|
1546
|
+
ok( ibody, "Check existance of IFrame body" );
|
1542
1547
|
|
1543
|
-
|
1548
|
+
equals( $("span", ibody).text(), "span text", "Find span in IFrame and check its text" );
|
1544
1549
|
|
1545
|
-
|
1546
|
-
|
1550
|
+
$(ibody).append("<div>init text</div>");
|
1551
|
+
equals( $("div", ibody).length, 2, "Check the original div and the new div are in IFrame" );
|
1547
1552
|
|
1548
|
-
|
1553
|
+
equals( $("div:last", ibody).text(), "init text", "Add text to div in IFrame" );
|
1549
1554
|
|
1550
|
-
|
1551
|
-
|
1555
|
+
$("div:last", ibody).text("div text");
|
1556
|
+
equals( $("div:last", ibody).text(), "div text", "Add text to div in IFrame" );
|
1552
1557
|
|
1553
|
-
|
1554
|
-
|
1558
|
+
$("div:last", ibody).remove();
|
1559
|
+
equals( $("div", ibody).length, 1, "Delete the div and check only one div left in IFrame" );
|
1555
1560
|
|
1556
|
-
|
1561
|
+
equals( $("div", ibody).text(), "span text", "Make sure the correct div is still left after deletion in IFrame" );
|
1557
1562
|
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1563
|
+
$("<table/>", ibody).append("<tr><td>cell</td></tr>").appendTo(ibody);
|
1564
|
+
$("table", ibody).remove();
|
1565
|
+
equals( $("div", ibody).length, 1, "Check for JS error on add and delete of a table in IFrame" );
|
1561
1566
|
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1567
|
+
// using contents will get comments regular, text, and comment nodes
|
1568
|
+
var c = $("#nonnodes").contents().contents();
|
1569
|
+
equals( c.length, 1, "Check node,textnode,comment contents is just one" );
|
1570
|
+
equals( c[0].nodeValue, "hi", "Check node,textnode,comment contents is just the one from span" );
|
1566
1571
|
});
|