lady_josephine 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (304) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +32 -0
  4. data/app/assets/fonts/lady_josephine/icons/icons.eot +0 -0
  5. data/app/assets/fonts/lady_josephine/icons/icons.svg +215 -0
  6. data/app/assets/fonts/lady_josephine/icons/icons.ttf +0 -0
  7. data/app/assets/fonts/lady_josephine/icons/icons.woff +0 -0
  8. data/app/assets/javascripts/lady_josephine/blocks/facebook.js +25 -0
  9. data/app/assets/javascripts/lady_josephine/blocks/instagram.js +22 -0
  10. data/app/assets/javascripts/lady_josephine/blocks/soundcloud.js +24 -0
  11. data/app/assets/javascripts/lady_josephine/blocks/twitter.js +25 -0
  12. data/app/assets/javascripts/lady_josephine/blocks/vimeo.js +55 -0
  13. data/app/assets/javascripts/lady_josephine/blocks/youtube.js +64 -0
  14. data/app/assets/javascripts/lady_josephine/editor.js +40 -0
  15. data/app/assets/javascripts/lady_josephine/lady_josephine.js +4 -0
  16. data/app/assets/javascripts/lady_josephine/lady_josephine_view.js +6 -0
  17. data/app/assets/stylesheets/lady_josephine/content.sass +33 -0
  18. data/app/assets/stylesheets/lady_josephine/icons.sass +175 -0
  19. data/app/assets/stylesheets/lady_josephine/lady_josephine.sass +6 -0
  20. data/app/assets/stylesheets/lady_josephine/sir_trevor.sass +619 -0
  21. data/app/assets/stylesheets/lady_josephine/vars.sass +36 -0
  22. data/app/controllers/lady_josephine/application_controller.rb +4 -0
  23. data/app/controllers/lady_josephine/editor_controller.rb +40 -0
  24. data/app/controllers/lady_josephine/images_controller.rb +26 -0
  25. data/app/helpers/lady_josephine/helper.rb +25 -0
  26. data/app/helpers/lady_josephine/sir_trevor_helper.rb +172 -0
  27. data/app/models/lady_josephine/concerns/model.rb +29 -0
  28. data/app/models/lady_josephine/concerns/pingable.rb +28 -0
  29. data/app/models/lady_josephine/concerns/server_uuid.rb +24 -0
  30. data/app/models/lady_josephine/concerns/sir_trevor_images.rb +38 -0
  31. data/app/models/lady_josephine/image.rb +41 -0
  32. data/app/uploader/lady_josephine/base_uploader.rb +47 -0
  33. data/app/uploader/lady_josephine/image_uploader.rb +149 -0
  34. data/app/views/lady_josephine/blocks/_audio_block.haml +2 -0
  35. data/app/views/lady_josephine/blocks/_definition_block.haml +4 -0
  36. data/app/views/lady_josephine/blocks/_divider_block.haml +2 -0
  37. data/app/views/lady_josephine/blocks/_extended_image_block.haml +63 -0
  38. data/app/views/lady_josephine/blocks/_extended_quote_block.haml +5 -0
  39. data/app/views/lady_josephine/blocks/_extended_tweet_block.haml +2 -0
  40. data/app/views/lady_josephine/blocks/_facebook_post_block.haml +2 -0
  41. data/app/views/lady_josephine/blocks/_heading_block.haml +2 -0
  42. data/app/views/lady_josephine/blocks/_html_block.haml +1 -0
  43. data/app/views/lady_josephine/blocks/_instagram_block.haml +2 -0
  44. data/app/views/lady_josephine/blocks/_list_block.haml +3 -0
  45. data/app/views/lady_josephine/blocks/_quote_block.haml +5 -0
  46. data/app/views/lady_josephine/blocks/_text_block.html.haml +2 -0
  47. data/app/views/lady_josephine/blocks/_video_block.haml +9 -0
  48. data/config/routes.rb +9 -0
  49. data/db/migrate/20160222151500_lady_josephine_image.rb +18 -0
  50. data/lib/generators/lady_josephine_migration/USAGE +9 -0
  51. data/lib/generators/lady_josephine_migration/lady_josephine_migration_generator.rb +17 -0
  52. data/lib/generators/lady_josephine_migration/templates/migration.rb +9 -0
  53. data/lib/lady_josephine.rb +18 -0
  54. data/lib/lady_josephine/engine.rb +18 -0
  55. data/lib/lady_josephine/redcarpet/custom_markdown_formatter.rb +63 -0
  56. data/lib/lady_josephine/renderer/sir_trevor_renderer.rb +16 -0
  57. data/lib/lady_josephine/version.rb +3 -0
  58. data/lib/lady_josephine/whitelist.rb +26 -0
  59. data/lib/tasks/lady_josephine_tasks.rake +4 -0
  60. data/spec/controllers/lady_josephine/editor_controller_spec.rb +58 -0
  61. data/spec/dummy/README.rdoc +28 -0
  62. data/spec/dummy/Rakefile +6 -0
  63. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  64. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  65. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  66. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  67. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  68. data/spec/dummy/bin/bundle +3 -0
  69. data/spec/dummy/bin/rails +4 -0
  70. data/spec/dummy/bin/rake +4 -0
  71. data/spec/dummy/bin/setup +29 -0
  72. data/spec/dummy/config.ru +4 -0
  73. data/spec/dummy/config/application.rb +26 -0
  74. data/spec/dummy/config/boot.rb +5 -0
  75. data/spec/dummy/config/database.yml +25 -0
  76. data/spec/dummy/config/environment.rb +5 -0
  77. data/spec/dummy/config/environments/development.rb +41 -0
  78. data/spec/dummy/config/environments/production.rb +79 -0
  79. data/spec/dummy/config/environments/test.rb +42 -0
  80. data/spec/dummy/config/initializers/assets.rb +11 -0
  81. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  82. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  83. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  84. data/spec/dummy/config/initializers/inflections.rb +16 -0
  85. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  86. data/spec/dummy/config/initializers/session_store.rb +3 -0
  87. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  88. data/spec/dummy/config/locales/en.yml +23 -0
  89. data/spec/dummy/config/routes.rb +4 -0
  90. data/spec/dummy/config/secrets.yml +22 -0
  91. data/spec/dummy/db/development.sqlite3 +0 -0
  92. data/spec/dummy/db/schema.rb +16 -0
  93. data/spec/dummy/db/test.sqlite3 +0 -0
  94. data/spec/dummy/log/bla +0 -0
  95. data/spec/dummy/public/404.html +67 -0
  96. data/spec/dummy/public/422.html +67 -0
  97. data/spec/dummy/public/500.html +66 -0
  98. data/spec/dummy/public/favicon.ico +0 -0
  99. data/spec/spec_helper.rb +17 -0
  100. data/vendor/assets/components/Eventable/README.md +12 -0
  101. data/vendor/assets/components/Eventable/bower.json +10 -0
  102. data/vendor/assets/components/Eventable/component.json +11 -0
  103. data/vendor/assets/components/Eventable/eventable.js +207 -0
  104. data/vendor/assets/components/Eventable/package.json +15 -0
  105. data/vendor/assets/components/jquery-autosize/bower.json +30 -0
  106. data/vendor/assets/components/jquery-autosize/demo.html +36 -0
  107. data/vendor/assets/components/jquery-autosize/jquery.autosize.js +273 -0
  108. data/vendor/assets/components/jquery-autosize/jquery.autosize.min.js +6 -0
  109. data/vendor/assets/components/jquery-autosize/package.json +32 -0
  110. data/vendor/assets/components/jquery-autosize/readme.md +216 -0
  111. data/vendor/assets/components/jquery/AUTHORS.txt +163 -0
  112. data/vendor/assets/components/jquery/CONTRIBUTING.md +216 -0
  113. data/vendor/assets/components/jquery/Gruntfile.js +496 -0
  114. data/vendor/assets/components/jquery/MIT-LICENSE.txt +21 -0
  115. data/vendor/assets/components/jquery/README.md +415 -0
  116. data/vendor/assets/components/jquery/build/release-notes.js +59 -0
  117. data/vendor/assets/components/jquery/build/release.js +246 -0
  118. data/vendor/assets/components/jquery/component.json +13 -0
  119. data/vendor/assets/components/jquery/composer.json +35 -0
  120. data/vendor/assets/components/jquery/jquery-migrate.js +496 -0
  121. data/vendor/assets/components/jquery/jquery-migrate.min.js +3 -0
  122. data/vendor/assets/components/jquery/jquery.js +9597 -0
  123. data/vendor/assets/components/jquery/jquery.min.js +5 -0
  124. data/vendor/assets/components/jquery/jquery.min.map +1 -0
  125. data/vendor/assets/components/jquery/package.json +39 -0
  126. data/vendor/assets/components/jquery/speed/benchmark.js +15 -0
  127. data/vendor/assets/components/jquery/speed/benchmarker.css +65 -0
  128. data/vendor/assets/components/jquery/speed/benchmarker.js +181 -0
  129. data/vendor/assets/components/jquery/speed/closest.html +39 -0
  130. data/vendor/assets/components/jquery/speed/css.html +82 -0
  131. data/vendor/assets/components/jquery/speed/event.html +58 -0
  132. data/vendor/assets/components/jquery/speed/filter.html +183 -0
  133. data/vendor/assets/components/jquery/speed/find.html +179 -0
  134. data/vendor/assets/components/jquery/speed/index.html +72 -0
  135. data/vendor/assets/components/jquery/speed/jquery-basis.js +6238 -0
  136. data/vendor/assets/components/jquery/speed/slice.vs.concat.html +47 -0
  137. data/vendor/assets/components/jquery/src/ajax.js +851 -0
  138. data/vendor/assets/components/jquery/src/ajax/jsonp.js +80 -0
  139. data/vendor/assets/components/jquery/src/ajax/script.js +86 -0
  140. data/vendor/assets/components/jquery/src/ajax/xhr.js +207 -0
  141. data/vendor/assets/components/jquery/src/attributes.js +661 -0
  142. data/vendor/assets/components/jquery/src/callbacks.js +196 -0
  143. data/vendor/assets/components/jquery/src/core.js +949 -0
  144. data/vendor/assets/components/jquery/src/css.js +679 -0
  145. data/vendor/assets/components/jquery/src/data.js +340 -0
  146. data/vendor/assets/components/jquery/src/deferred.js +141 -0
  147. data/vendor/assets/components/jquery/src/deprecated.js +4 -0
  148. data/vendor/assets/components/jquery/src/dimensions.js +41 -0
  149. data/vendor/assets/components/jquery/src/effects.js +730 -0
  150. data/vendor/assets/components/jquery/src/event-alias.js +15 -0
  151. data/vendor/assets/components/jquery/src/event.js +991 -0
  152. data/vendor/assets/components/jquery/src/exports.js +18 -0
  153. data/vendor/assets/components/jquery/src/intro.js +20 -0
  154. data/vendor/assets/components/jquery/src/manipulation.js +796 -0
  155. data/vendor/assets/components/jquery/src/offset.js +169 -0
  156. data/vendor/assets/components/jquery/src/outro.js +2 -0
  157. data/vendor/assets/components/jquery/src/queue.js +147 -0
  158. data/vendor/assets/components/jquery/src/serialize.js +99 -0
  159. data/vendor/assets/components/jquery/src/sizzle-jquery.js +9 -0
  160. data/vendor/assets/components/jquery/src/support.js +241 -0
  161. data/vendor/assets/components/jquery/src/traversing.js +275 -0
  162. data/vendor/assets/components/jquery/test/csp.php +16 -0
  163. data/vendor/assets/components/jquery/test/data/1x1.jpg +0 -0
  164. data/vendor/assets/components/jquery/test/data/ajax/unreleasedXHR.html +25 -0
  165. data/vendor/assets/components/jquery/test/data/atom+xml.php +4 -0
  166. data/vendor/assets/components/jquery/test/data/badcall.js +1 -0
  167. data/vendor/assets/components/jquery/test/data/badjson.js +1 -0
  168. data/vendor/assets/components/jquery/test/data/cleanScript.html +10 -0
  169. data/vendor/assets/components/jquery/test/data/core/cc_on.html +22 -0
  170. data/vendor/assets/components/jquery/test/data/dashboard.xml +11 -0
  171. data/vendor/assets/components/jquery/test/data/dimensions/documentLarge.html +17 -0
  172. data/vendor/assets/components/jquery/test/data/dimensions/documentSmall.html +21 -0
  173. data/vendor/assets/components/jquery/test/data/echoData.php +1 -0
  174. data/vendor/assets/components/jquery/test/data/echoQuery.php +1 -0
  175. data/vendor/assets/components/jquery/test/data/errorWithText.php +5 -0
  176. data/vendor/assets/components/jquery/test/data/etag.php +21 -0
  177. data/vendor/assets/components/jquery/test/data/evalScript.php +1 -0
  178. data/vendor/assets/components/jquery/test/data/event/longLoadScript.php +4 -0
  179. data/vendor/assets/components/jquery/test/data/event/promiseReady.html +17 -0
  180. data/vendor/assets/components/jquery/test/data/event/syncReady.html +23 -0
  181. data/vendor/assets/components/jquery/test/data/headers.php +18 -0
  182. data/vendor/assets/components/jquery/test/data/if_modified_since.php +20 -0
  183. data/vendor/assets/components/jquery/test/data/iframe.html +8 -0
  184. data/vendor/assets/components/jquery/test/data/jquery-1.8.2.ajax_xhr.min.js +2 -0
  185. data/vendor/assets/components/jquery/test/data/json.php +13 -0
  186. data/vendor/assets/components/jquery/test/data/json_obj.js +1 -0
  187. data/vendor/assets/components/jquery/test/data/jsonp.php +14 -0
  188. data/vendor/assets/components/jquery/test/data/manipulation/iframe-denied.html +36 -0
  189. data/vendor/assets/components/jquery/test/data/name.html +1 -0
  190. data/vendor/assets/components/jquery/test/data/name.php +24 -0
  191. data/vendor/assets/components/jquery/test/data/nocontent.php +5 -0
  192. data/vendor/assets/components/jquery/test/data/offset/absolute.html +41 -0
  193. data/vendor/assets/components/jquery/test/data/offset/body.html +26 -0
  194. data/vendor/assets/components/jquery/test/data/offset/fixed.html +34 -0
  195. data/vendor/assets/components/jquery/test/data/offset/relative.html +31 -0
  196. data/vendor/assets/components/jquery/test/data/offset/scroll.html +39 -0
  197. data/vendor/assets/components/jquery/test/data/offset/static.html +31 -0
  198. data/vendor/assets/components/jquery/test/data/offset/table.html +43 -0
  199. data/vendor/assets/components/jquery/test/data/params_html.php +12 -0
  200. data/vendor/assets/components/jquery/test/data/readywaitasset.js +1 -0
  201. data/vendor/assets/components/jquery/test/data/readywaitloader.js +25 -0
  202. data/vendor/assets/components/jquery/test/data/script.php +11 -0
  203. data/vendor/assets/components/jquery/test/data/selector/html5_selector.html +114 -0
  204. data/vendor/assets/components/jquery/test/data/selector/sizzle_cache.html +21 -0
  205. data/vendor/assets/components/jquery/test/data/statusText.php +5 -0
  206. data/vendor/assets/components/jquery/test/data/support/bodyBackground.html +28 -0
  207. data/vendor/assets/components/jquery/test/data/support/shrinkWrapBlocks.html +23 -0
  208. data/vendor/assets/components/jquery/test/data/support/testElementCrash.html +17 -0
  209. data/vendor/assets/components/jquery/test/data/test.html +7 -0
  210. data/vendor/assets/components/jquery/test/data/test.js +3 -0
  211. data/vendor/assets/components/jquery/test/data/test.php +7 -0
  212. data/vendor/assets/components/jquery/test/data/test2.html +5 -0
  213. data/vendor/assets/components/jquery/test/data/test3.html +3 -0
  214. data/vendor/assets/components/jquery/test/data/testinit.js +269 -0
  215. data/vendor/assets/components/jquery/test/data/testrunner.js +368 -0
  216. data/vendor/assets/components/jquery/test/data/testsuite.css +155 -0
  217. data/vendor/assets/components/jquery/test/data/text.php +12 -0
  218. data/vendor/assets/components/jquery/test/data/ua.txt +272 -0
  219. data/vendor/assets/components/jquery/test/data/with_fries.xml +25 -0
  220. data/vendor/assets/components/jquery/test/data/with_fries_over_jsonp.php +7 -0
  221. data/vendor/assets/components/jquery/test/delegatetest.html +228 -0
  222. data/vendor/assets/components/jquery/test/hovertest.html +158 -0
  223. data/vendor/assets/components/jquery/test/index.html +330 -0
  224. data/vendor/assets/components/jquery/test/localfile.html +75 -0
  225. data/vendor/assets/components/jquery/test/networkerror.html +84 -0
  226. data/vendor/assets/components/jquery/test/polluted.php +110 -0
  227. data/vendor/assets/components/jquery/test/readywait.html +70 -0
  228. data/vendor/assets/components/jquery/test/unit/ajax.js +1971 -0
  229. data/vendor/assets/components/jquery/test/unit/attributes.js +1332 -0
  230. data/vendor/assets/components/jquery/test/unit/callbacks.js +326 -0
  231. data/vendor/assets/components/jquery/test/unit/core.js +1332 -0
  232. data/vendor/assets/components/jquery/test/unit/css.js +1036 -0
  233. data/vendor/assets/components/jquery/test/unit/data.js +636 -0
  234. data/vendor/assets/components/jquery/test/unit/deferred.js +440 -0
  235. data/vendor/assets/components/jquery/test/unit/deprecated.js +1 -0
  236. data/vendor/assets/components/jquery/test/unit/dimensions.js +461 -0
  237. data/vendor/assets/components/jquery/test/unit/effects.js +2050 -0
  238. data/vendor/assets/components/jquery/test/unit/event.js +2690 -0
  239. data/vendor/assets/components/jquery/test/unit/exports.js +7 -0
  240. data/vendor/assets/components/jquery/test/unit/manipulation.js +2242 -0
  241. data/vendor/assets/components/jquery/test/unit/offset.js +549 -0
  242. data/vendor/assets/components/jquery/test/unit/queue.js +316 -0
  243. data/vendor/assets/components/jquery/test/unit/selector.js +185 -0
  244. data/vendor/assets/components/jquery/test/unit/serialize.js +146 -0
  245. data/vendor/assets/components/jquery/test/unit/support.js +384 -0
  246. data/vendor/assets/components/jquery/test/unit/traversing.js +667 -0
  247. data/vendor/assets/components/jquery/test/xhtml.php +5 -0
  248. data/vendor/assets/components/sir-trevor-js/CHANGELOG.md +44 -0
  249. data/vendor/assets/components/sir-trevor-js/Gemfile +3 -0
  250. data/vendor/assets/components/sir-trevor-js/Gemfile.lock +10 -0
  251. data/vendor/assets/components/sir-trevor-js/Gruntfile.js +109 -0
  252. data/vendor/assets/components/sir-trevor-js/MIT-LICENCE +20 -0
  253. data/vendor/assets/components/sir-trevor-js/Readme.md +84 -0
  254. data/vendor/assets/components/sir-trevor-js/bower.json +21 -0
  255. data/vendor/assets/components/sir-trevor-js/component.json +42 -0
  256. data/vendor/assets/components/sir-trevor-js/contributing.md +74 -0
  257. data/vendor/assets/components/sir-trevor-js/examples-component/component.json +14 -0
  258. data/vendor/assets/components/sir-trevor-js/examples-component/index.html +33 -0
  259. data/vendor/assets/components/sir-trevor-js/examples-component/index.js +29 -0
  260. data/vendor/assets/components/sir-trevor-js/examples-component/javascript/example_block.js +203 -0
  261. data/vendor/assets/components/sir-trevor-js/examples-component/javascript/limit_chars.js +46 -0
  262. data/vendor/assets/components/sir-trevor-js/examples-component/sir-trevor.gif +0 -0
  263. data/vendor/assets/components/sir-trevor-js/locales/cn.js +51 -0
  264. data/vendor/assets/components/sir-trevor-js/locales/de.js +51 -0
  265. data/vendor/assets/components/sir-trevor-js/locales/es.js +51 -0
  266. data/vendor/assets/components/sir-trevor-js/locales/fi.js +51 -0
  267. data/vendor/assets/components/sir-trevor-js/locales/fr.js +51 -0
  268. data/vendor/assets/components/sir-trevor-js/locales/pt.js +52 -0
  269. data/vendor/assets/components/sir-trevor-js/package.json +23 -0
  270. data/vendor/assets/components/sir-trevor-js/sir-trevor-icons.css +6 -0
  271. data/vendor/assets/components/sir-trevor-js/sir-trevor.css +393 -0
  272. data/vendor/assets/components/sir-trevor-js/sir-trevor.css.map +7 -0
  273. data/vendor/assets/components/sir-trevor-js/sir-trevor.js +5481 -0
  274. data/vendor/assets/components/sir-trevor-js/sir-trevor.min.js +13 -0
  275. data/vendor/assets/components/underscore/CNAME +1 -0
  276. data/vendor/assets/components/underscore/CONTRIBUTING.md +9 -0
  277. data/vendor/assets/components/underscore/LICENSE +22 -0
  278. data/vendor/assets/components/underscore/README.md +19 -0
  279. data/vendor/assets/components/underscore/Rakefile +10 -0
  280. data/vendor/assets/components/underscore/docs/docco.css +192 -0
  281. data/vendor/assets/components/underscore/docs/favicon.ico +0 -0
  282. data/vendor/assets/components/underscore/docs/images/background.png +0 -0
  283. data/vendor/assets/components/underscore/docs/images/underscore.png +0 -0
  284. data/vendor/assets/components/underscore/docs/underscore.html +823 -0
  285. data/vendor/assets/components/underscore/favicon.ico +0 -0
  286. data/vendor/assets/components/underscore/index.html +2467 -0
  287. data/vendor/assets/components/underscore/index.js +1 -0
  288. data/vendor/assets/components/underscore/package.json +16 -0
  289. data/vendor/assets/components/underscore/test/arrays.js +200 -0
  290. data/vendor/assets/components/underscore/test/chaining.js +59 -0
  291. data/vendor/assets/components/underscore/test/collections.js +453 -0
  292. data/vendor/assets/components/underscore/test/functions.js +265 -0
  293. data/vendor/assets/components/underscore/test/index.html +44 -0
  294. data/vendor/assets/components/underscore/test/objects.js +570 -0
  295. data/vendor/assets/components/underscore/test/speed.js +75 -0
  296. data/vendor/assets/components/underscore/test/utility.js +266 -0
  297. data/vendor/assets/components/underscore/test/vendor/jquery.js +9404 -0
  298. data/vendor/assets/components/underscore/test/vendor/jslitmus.js +670 -0
  299. data/vendor/assets/components/underscore/test/vendor/qunit.css +235 -0
  300. data/vendor/assets/components/underscore/test/vendor/qunit.js +1977 -0
  301. data/vendor/assets/components/underscore/test/vendor/runner.js +98 -0
  302. data/vendor/assets/components/underscore/underscore-min.js +1 -0
  303. data/vendor/assets/components/underscore/underscore.js +1226 -0
  304. metadata +473 -0
@@ -0,0 +1,7 @@
1
+ module("exports", { teardown: moduleTeardown });
2
+
3
+ test("amdModule", function() {
4
+ expect(1);
5
+
6
+ equal( jQuery, amdDefined, "Make sure defined module matches jQuery" );
7
+ });
@@ -0,0 +1,2242 @@
1
+ module( "manipulation", {
2
+ teardown: moduleTeardown
3
+ });
4
+
5
+ // Ensure that an extended Array prototype doesn't break jQuery
6
+ Array.prototype.arrayProtoFn = function( arg ) {
7
+ throw("arrayProtoFn should not be called");
8
+ };
9
+
10
+ var manipulationBareObj = function( value ) {
11
+ return value;
12
+ };
13
+
14
+ var manipulationFunctionReturningObj = function( value ) {
15
+ return (function() {
16
+ return value;
17
+ });
18
+ };
19
+
20
+ /*
21
+ ======== local reference =======
22
+ manipulationBareObj and manipulationFunctionReturningObj can be used to test passing functions to setters
23
+ See testVal below for an example
24
+
25
+ bareObj( value );
26
+ This function returns whatever value is passed in
27
+
28
+ functionReturningObj( value );
29
+ Returns a function that returns the value
30
+ */
31
+
32
+ test( "text()", function() {
33
+
34
+ expect( 5 );
35
+
36
+ var expected, frag, $newLineTest;
37
+
38
+ expected = "This link has class=\"blog\": Simon Willison's Weblog";
39
+ equal( jQuery("#sap").text(), expected, "Check for merged text of more then one element." );
40
+
41
+ // Check serialization of text values
42
+ equal( jQuery(document.createTextNode("foo")).text(), "foo", "Text node was retreived from .text()." );
43
+ notEqual( jQuery(document).text(), "", "Retrieving text for the document retrieves all text (#10724)." );
44
+
45
+ // Retrieve from document fragments #10864
46
+ frag = document.createDocumentFragment();
47
+ frag.appendChild( document.createTextNode("foo") );
48
+
49
+ equal( jQuery(frag).text(), "foo", "Document Fragment Text node was retreived from .text()." );
50
+
51
+ $newLineTest = jQuery("<div>test<br/>testy</div>").appendTo("#moretests");
52
+ $newLineTest.find("br").replaceWith("\n");
53
+ equal( $newLineTest.text(), "test\ntesty", "text() does not remove new lines (#11153)" );
54
+
55
+ $newLineTest.remove();
56
+ });
57
+
58
+ test( "text(undefined)", function() {
59
+
60
+ expect( 1 );
61
+
62
+ equal( jQuery("#foo").text("<div").text(undefined)[ 0 ].innerHTML, "&lt;div", ".text(undefined) is chainable (#5571)" );
63
+ });
64
+
65
+ var testText = function( valueObj ) {
66
+
67
+ expect( 4 );
68
+
69
+ var val, j;
70
+
71
+ val = valueObj("<div><b>Hello</b> cruel world!</div>");
72
+ equal( jQuery("#foo").text(val)[ 0 ].innerHTML.replace(/>/g, "&gt;"), "&lt;div&gt;&lt;b&gt;Hello&lt;/b&gt; cruel world!&lt;/div&gt;", "Check escaped text" );
73
+
74
+ // using contents will get comments regular, text, and comment nodes
75
+ j = jQuery("#nonnodes").contents();
76
+ j.text( valueObj("hi!") );
77
+ equal( jQuery( j[ 0 ] ).text(), "hi!", "Check node,textnode,comment with text()" );
78
+ equal( j[ 1 ].nodeValue, " there ", "Check node,textnode,comment with text()" );
79
+
80
+ // Blackberry 4.6 doesn't maintain comments in the DOM
81
+ equal( jQuery("#nonnodes")[ 0 ].childNodes.length < 3 ? 8 : j[ 2 ].nodeType, 8, "Check node,textnode,comment with text()" );
82
+ };
83
+
84
+ test( "text(String)", function() {
85
+ testText( manipulationBareObj );
86
+ });
87
+
88
+ test( "text(Function)", function() {
89
+ testText( manipulationFunctionReturningObj );
90
+ });
91
+
92
+ test( "text(Function) with incoming value", function() {
93
+
94
+ expect( 2 );
95
+
96
+ var old = "This link has class=\"blog\": Simon Willison's Weblog";
97
+
98
+ jQuery("#sap").text(function( i, val ) {
99
+ equal( val, old, "Make sure the incoming value is correct." );
100
+ return "foobar";
101
+ });
102
+
103
+ equal( jQuery("#sap").text(), "foobar", "Check for merged text of more then one element." );
104
+ });
105
+
106
+ var testWrap = function( val ) {
107
+
108
+ expect( 19 );
109
+
110
+ var defaultText, result, j, i, cacheLength;
111
+
112
+ defaultText = "Try them out:",
113
+ result = jQuery("#first").wrap( val("<div class='red'><span></span></div>") ).text();
114
+
115
+ equal( defaultText, result, "Check for wrapping of on-the-fly html" );
116
+ ok( jQuery("#first").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
117
+
118
+ QUnit.reset();
119
+ result = jQuery("#first").wrap( val(document.getElementById("empty")) ).parent();
120
+ ok( result.is("ol"), "Check for element wrapping" );
121
+ equal( result.text(), defaultText, "Check for element wrapping" );
122
+
123
+ QUnit.reset();
124
+ jQuery("#check1").on( "click", function() {
125
+ var checkbox = this;
126
+
127
+ ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
128
+ jQuery( checkbox ).wrap( val("<div id='c1' style='display:none;'></div>") );
129
+ ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
130
+ }).prop( "checked", false )[ 0 ].click();
131
+
132
+ // using contents will get comments regular, text, and comment nodes
133
+ j = jQuery("#nonnodes").contents();
134
+ j.wrap( val("<i></i>") );
135
+
136
+ // Blackberry 4.6 doesn't maintain comments in the DOM
137
+ equal( jQuery("#nonnodes > i").length, jQuery("#nonnodes")[ 0 ].childNodes.length, "Check node,textnode,comment wraps ok" );
138
+ equal( jQuery("#nonnodes > i").text(), j.text(), "Check node,textnode,comment wraps doesn't hurt text" );
139
+
140
+ // Try wrapping a disconnected node
141
+ cacheLength = 0;
142
+ for ( i in jQuery.cache ) {
143
+ cacheLength++;
144
+ }
145
+
146
+ j = jQuery("<label/>").wrap( val("<li/>") );
147
+ equal( j[ 0 ] .nodeName.toUpperCase(), "LABEL", "Element is a label" );
148
+ equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped" );
149
+
150
+ for ( i in jQuery.cache ) {
151
+ cacheLength--;
152
+ }
153
+ equal( cacheLength, 0, "No memory leak in jQuery.cache (bug #7165)" );
154
+
155
+ // Wrap an element containing a text node
156
+ j = jQuery("<span/>").wrap("<div>test</div>");
157
+ equal( j[ 0 ].previousSibling.nodeType, 3, "Make sure the previous node is a text element" );
158
+ equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "DIV", "And that we're in the div element." );
159
+
160
+ // Try to wrap an element with multiple elements (should fail)
161
+ j = jQuery("<div><span></span></div>").children().wrap("<p></p><div></div>");
162
+ equal( j[ 0 ].parentNode.parentNode.childNodes.length, 1, "There should only be one element wrapping." );
163
+ equal( j.length, 1, "There should only be one element (no cloning)." );
164
+ equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "P", "The span should be in the paragraph." );
165
+
166
+ // Wrap an element with a jQuery set
167
+ j = jQuery("<span/>").wrap( jQuery("<div></div>") );
168
+ equal( j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." );
169
+
170
+ // Wrap an element with a jQuery set and event
171
+ result = jQuery("<div></div>").on( "click", function() {
172
+ ok( true, "Event triggered." );
173
+
174
+ // Remove handlers on detached elements
175
+ result.unbind();
176
+ jQuery(this).unbind();
177
+ });
178
+
179
+ j = jQuery("<span/>").wrap( result );
180
+ equal( j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." );
181
+
182
+ j.parent().trigger("click");
183
+
184
+ // clean up attached elements
185
+ QUnit.reset();
186
+ };
187
+
188
+ test( "wrap(String|Element)", function() {
189
+ testWrap( manipulationBareObj );
190
+ });
191
+
192
+ test( "wrap(Function)", function() {
193
+ testWrap( manipulationFunctionReturningObj );
194
+ });
195
+
196
+ test( "wrap(Function) with index (#10177)", function() {
197
+ var expectedIndex = 0,
198
+ targets = jQuery("#qunit-fixture p");
199
+
200
+ expect( targets.length );
201
+ targets.wrap(function(i) {
202
+ equal( i, expectedIndex, "Check if the provided index (" + i + ") is as expected (" + expectedIndex + ")" );
203
+ expectedIndex++;
204
+
205
+ return "<div id='wrap_index_'" + i + "'></div>";
206
+ });
207
+ });
208
+
209
+ test( "wrap(String) consecutive elements (#10177)", function() {
210
+ var targets = jQuery("#qunit-fixture p");
211
+
212
+ expect( targets.length * 2 );
213
+ targets.wrap("<div class='wrapper'></div>");
214
+
215
+ targets.each(function() {
216
+ var $this = jQuery(this);
217
+
218
+ ok( $this.parent().is(".wrapper"), "Check each elements parent is correct (.wrapper)" );
219
+ equal( $this.siblings().length, 0, "Each element should be wrapped individually" );
220
+ });
221
+ });
222
+
223
+ var testWrapAll = function( val ) {
224
+
225
+ expect( 8 );
226
+
227
+ var prev, p, result;
228
+
229
+ prev = jQuery("#firstp")[ 0 ].previousSibling;
230
+ p = jQuery("#firstp,#first")[ 0 ].parentNode;
231
+ result = jQuery("#firstp,#first").wrapAll( val("<div class='red'><div class='tmp'></div></div>") );
232
+
233
+ equal( result.parent().length, 1, "Check for wrapping of on-the-fly html" );
234
+ ok( jQuery("#first").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
235
+ ok( jQuery("#firstp").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
236
+ equal( jQuery("#first").parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
237
+ equal( jQuery("#first").parent().parent()[ 0 ].parentNode, p, "Correct Parent" );
238
+
239
+ QUnit.reset();
240
+ prev = jQuery("#firstp")[ 0 ].previousSibling;
241
+ p = jQuery("#first")[ 0 ].parentNode;
242
+ result = jQuery("#firstp,#first").wrapAll( val(document.getElementById("empty")) );
243
+
244
+ equal( jQuery("#first").parent()[ 0 ], jQuery("#firstp").parent()[ 0 ], "Same Parent" );
245
+ equal( jQuery("#first").parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
246
+ equal( jQuery("#first").parent()[ 0 ].parentNode, p, "Correct Parent" );
247
+ };
248
+
249
+ test( "wrapAll(String|Element)", function() {
250
+ testWrapAll( manipulationBareObj );
251
+ });
252
+
253
+ var testWrapInner = function( val ) {
254
+
255
+ expect( 11 );
256
+
257
+ var num, result;
258
+
259
+ num = jQuery("#first").children().length;
260
+ result = jQuery("#first").wrapInner( val("<div class='red'><div id='tmp'></div></div>") );
261
+
262
+ equal( jQuery("#first").children().length, 1, "Only one child" );
263
+ ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
264
+ equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
265
+
266
+ QUnit.reset();
267
+ num = jQuery("#first").html("foo<div>test</div><div>test2</div>").children().length;
268
+ result = jQuery("#first").wrapInner( val("<div class='red'><div id='tmp'></div></div>") );
269
+ equal( jQuery("#first").children().length, 1, "Only one child" );
270
+ ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
271
+ equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
272
+
273
+ QUnit.reset();
274
+ num = jQuery("#first").children().length;
275
+ result = jQuery("#first").wrapInner( val(document.getElementById("empty")) );
276
+ equal( jQuery("#first").children().length, 1, "Only one child" );
277
+ ok( jQuery("#first").children().is("#empty"), "Verify Right Element" );
278
+ equal( jQuery("#first").children().children().length, num, "Verify Elements Intact" );
279
+
280
+ var div = jQuery("<div/>");
281
+ div.wrapInner( val("<span></span>") );
282
+ equal( div.children().length, 1, "The contents were wrapped." );
283
+ equal( div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted." );
284
+ };
285
+
286
+ test( "wrapInner(String|Element)", function() {
287
+ testWrapInner( manipulationBareObj );
288
+ });
289
+
290
+ test( "wrapInner(Function)", function() {
291
+ testWrapInner( manipulationFunctionReturningObj );
292
+ });
293
+
294
+ test( "unwrap()", function() {
295
+
296
+ expect( 9 );
297
+
298
+ jQuery("body").append(" <div id='unwrap' style='display: none;'> <div id='unwrap1'> <span class='unwrap'>a</span> <span class='unwrap'>b</span> </div> <div id='unwrap2'> <span class='unwrap'>c</span> <span class='unwrap'>d</span> </div> <div id='unwrap3'> <b><span class='unwrap unwrap3'>e</span></b> <b><span class='unwrap unwrap3'>f</span></b> </div> </div>");
299
+
300
+ var abcd = jQuery("#unwrap1 > span, #unwrap2 > span").get(),
301
+ abcdef = jQuery("#unwrap span").get();
302
+
303
+ equal( jQuery("#unwrap1 span").add("#unwrap2 span:first").unwrap().length, 3, "make #unwrap1 and #unwrap2 go away" );
304
+ deepEqual( jQuery("#unwrap > span").get(), abcd, "all four spans should still exist" );
305
+
306
+ deepEqual( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap3 > span").get(), "make all b in #unwrap3 go away" );
307
+
308
+ deepEqual( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap > span.unwrap3").get(), "make #unwrap3 go away" );
309
+
310
+ deepEqual( jQuery("#unwrap").children().get(), abcdef, "#unwrap only contains 6 child spans" );
311
+
312
+ deepEqual( jQuery("#unwrap > span").unwrap().get(), jQuery("body > span.unwrap").get(), "make the 6 spans become children of body" );
313
+
314
+ deepEqual( jQuery("body > span.unwrap").unwrap().get(), jQuery("body > span.unwrap").get(), "can't unwrap children of body" );
315
+ deepEqual( jQuery("body > span.unwrap").unwrap().get(), abcdef, "can't unwrap children of body" );
316
+
317
+ deepEqual( jQuery("body > span.unwrap").get(), abcdef, "body contains 6 .unwrap child spans" );
318
+
319
+ jQuery("body > span.unwrap").remove();
320
+ });
321
+
322
+ var testAppendForObject = function( valueObj, isFragment ) {
323
+ var $base,
324
+ type = isFragment ? " (DocumentFragment)" : " (Element)",
325
+ text = "This link has class=\"blog\": Simon Willison's Weblog",
326
+ el = document.getElementById("sap").cloneNode( true ),
327
+ first = document.getElementById("first"),
328
+ yahoo = document.getElementById("yahoo");
329
+
330
+ if ( isFragment ) {
331
+ $base = document.createDocumentFragment();
332
+ jQuery( el ).contents().each(function() {
333
+ $base.appendChild( this );
334
+ });
335
+ $base = jQuery( $base );
336
+ } else {
337
+ $base = jQuery( el );
338
+ }
339
+
340
+ equal( $base.clone().append( valueObj(first.cloneNode(true)) ).text(),
341
+ text + "Try them out:",
342
+ "Check for appending of element" + type
343
+ );
344
+
345
+ equal( $base.clone().append( valueObj([ first.cloneNode(true), yahoo.cloneNode(true) ]) ).text(),
346
+ text + "Try them out:Yahoo",
347
+ "Check for appending of array of elements" + type
348
+ );
349
+
350
+ equal( $base.clone().append( valueObj(jQuery("#yahoo, #first").clone()) ).text(),
351
+ text + "YahooTry them out:",
352
+ "Check for appending of jQuery object" + type
353
+ );
354
+
355
+ equal( $base.clone().append( valueObj( 5 ) ).text(),
356
+ text + "5",
357
+ "Check for appending a number" + type
358
+ );
359
+
360
+ equal( $base.clone().append( valueObj([ jQuery("#first").clone(), jQuery("#yahoo, #google").clone() ]) ).text(),
361
+ text + "Try them out:GoogleYahoo",
362
+ "Check for appending of array of jQuery objects"
363
+ );
364
+
365
+ equal( $base.clone().append( valueObj(" text with spaces ") ).text(),
366
+ text + " text with spaces ",
367
+ "Check for appending text with spaces" + type
368
+ );
369
+
370
+ equal( $base.clone().append( valueObj([]) ).text(),
371
+ text,
372
+ "Check for appending an empty array" + type
373
+ );
374
+
375
+ equal( $base.clone().append( valueObj("") ).text(),
376
+ text,
377
+ "Check for appending an empty string" + type
378
+ );
379
+
380
+ equal( $base.clone().append( valueObj(document.getElementsByTagName("foo")) ).text(),
381
+ text,
382
+ "Check for appending an empty nodelist" + type
383
+ );
384
+
385
+ equal( $base.clone().append( "<span></span>", "<span></span>", "<span></span>" ).children().length,
386
+ $base.children().length + 3,
387
+ "Make sure that multiple arguments works." + type
388
+ );
389
+
390
+ equal( $base.clone().append( valueObj(document.getElementById("form").cloneNode(true)) ).children("form").length,
391
+ 1,
392
+ "Check for appending a form (#910)" + type
393
+ );
394
+ };
395
+
396
+ var testAppend = function( valueObj ) {
397
+
398
+ expect( 78 );
399
+
400
+ testAppendForObject( valueObj, false );
401
+ testAppendForObject( valueObj, true );
402
+
403
+ var defaultText, result, message, iframe, iframeDoc, j, d,
404
+ $input, $radioChecked, $radioUnchecked, $radioParent, $map, $table;
405
+
406
+ defaultText = "Try them out:";
407
+ result = jQuery("#first").append( valueObj("<b>buga</b>") );
408
+
409
+ equal( result.text(), defaultText + "buga", "Check if text appending works" );
410
+ equal( jQuery("#select3").append( valueObj("<option value='appendTest'>Append Test</option>") ).find("option:last-child").attr("value"), "appendTest", "Appending html options to select element" );
411
+
412
+ jQuery("form").append( valueObj("<input name='radiotest' type='radio' checked='checked' />") );
413
+ jQuery("form input[name=radiotest]").each(function() {
414
+ ok( jQuery(this).is(":checked"), "Append checked radio" );
415
+ }).remove();
416
+
417
+ jQuery("form").append( valueObj("<input name='radiotest2' type='radio' checked = 'checked' />") );
418
+ jQuery("form input[name=radiotest2]").each(function() {
419
+ ok( jQuery(this).is(":checked"), "Append alternately formated checked radio" );
420
+ }).remove();
421
+
422
+ jQuery("form").append( valueObj("<input name='radiotest3' type='radio' checked />") );
423
+ jQuery("form input[name=radiotest3]").each(function() {
424
+ ok( jQuery(this).is(":checked"), "Append HTML5-formated checked radio" );
425
+ }).remove();
426
+
427
+ jQuery("form").append( valueObj("<input type='radio' checked='checked' name='radiotest4' />") );
428
+ jQuery("form input[name=radiotest4]").each(function() {
429
+ ok( jQuery(this).is(":checked"), "Append with name attribute after checked attribute" );
430
+ }).remove();
431
+
432
+ message = "Test for appending a DOM node to the contents of an iframe";
433
+ iframe = jQuery("#iframe")[ 0 ];
434
+ iframeDoc = iframe.contentDocument || iframe.contentWindow && iframe.contentWindow.document;
435
+
436
+ try {
437
+ if ( iframeDoc && iframeDoc.body ) {
438
+ equal( jQuery(iframeDoc.body).append( valueObj("<div id='success'>test</div>") )[ 0 ].lastChild.id, "success", message );
439
+ } else {
440
+ ok( true, message + " - can't test" );
441
+ }
442
+ } catch( e ) {
443
+ strictEqual( e.message || e, undefined, message );
444
+ }
445
+
446
+ jQuery("<fieldset/>").appendTo("#form").append( valueObj("<legend id='legend'>test</legend>") );
447
+ t( "Append legend", "#legend", [ "legend" ] );
448
+
449
+ $map = jQuery("<map/>").append( valueObj("<area id='map01' shape='rect' coords='50,50,150,150' href='http://www.jquery.com/' alt='jQuery'>") );
450
+
451
+ equal( $map[ 0 ].childNodes.length, 1, "The area was inserted." );
452
+ equal( $map[ 0 ].firstChild.nodeName.toLowerCase(), "area", "The area was inserted." );
453
+
454
+ jQuery("#select1").append( valueObj("<OPTION>Test</OPTION>") );
455
+ equal( jQuery("#select1 option:last").text(), "Test", "Appending OPTION (all caps)" );
456
+
457
+ jQuery("#select1").append( valueObj("<optgroup label='optgroup'><option>optgroup</option></optgroup>") );
458
+ equal( jQuery("#select1 optgroup").attr("label"), "optgroup", "Label attribute in newly inserted optgroup is correct" );
459
+ equal( jQuery("#select1 option:last").text(), "optgroup", "Appending optgroup" );
460
+
461
+ $table = jQuery("#table").empty();
462
+
463
+ jQuery.each( "thead tbody tfoot colgroup caption tr th td".split(" "), function( i, name ) {
464
+ $table.append( valueObj( "<" + name + "/>" ) );
465
+ ok( $table.find( name ).length >= 1, "Append " + name );
466
+ ok( jQuery.parseHTML( "<" + name + "/>" ).length, name + " wrapped correctly" );
467
+ });
468
+
469
+ jQuery("#table colgroup").append( valueObj("<col/>") );
470
+ equal( jQuery("#table colgroup col").length, 1, "Append col" );
471
+
472
+ jQuery("#form")
473
+ .append( valueObj("<select id='appendSelect1'></select>") )
474
+ .append( valueObj("<select id='appendSelect2'><option>Test</option></select>") );
475
+ t( "Append Select", "#appendSelect1, #appendSelect2", [ "appendSelect1", "appendSelect2" ] );
476
+
477
+ equal( "Two nodes", jQuery("<div />").append( "Two", " nodes" ).text(), "Appending two text nodes (#4011)" );
478
+ equal( jQuery("<div />").append( "1", "", 3 ).text(), "13", "If median is false-like value, subsequent arguments should not be ignored" );
479
+
480
+ // using contents will get comments regular, text, and comment nodes
481
+ j = jQuery("#nonnodes").contents();
482
+ d = jQuery("<div/>").appendTo("#nonnodes").append( j );
483
+
484
+ equal( jQuery("#nonnodes").length, 1, "Check node,textnode,comment append moved leaving just the div" );
485
+ equal( d.contents().length, 3, "Check node,textnode,comment append works" );
486
+ d.contents().appendTo("#nonnodes");
487
+ d.remove();
488
+ equal( jQuery("#nonnodes").contents().length, 3, "Check node,textnode,comment append cleanup worked" );
489
+
490
+ $input = jQuery("<input type='checkbox'/>").prop( "checked", true ).appendTo("#testForm");
491
+ equal( $input[ 0 ].checked, true, "A checked checkbox that is appended stays checked" );
492
+
493
+ $radioChecked = jQuery("input:radio[name='R1']").eq( 1 );
494
+ $radioParent = $radioChecked.parent();
495
+ $radioUnchecked = jQuery("<input type='radio' name='R1' checked='checked'/>").appendTo( $radioParent );
496
+ $radioChecked.trigger("click");
497
+ $radioUnchecked[ 0 ].checked = false;
498
+ $radioParent.wrap("<div></div>");
499
+ equal( $radioChecked[ 0 ].checked, true, "Reappending radios uphold which radio is checked" );
500
+ equal( $radioUnchecked[ 0 ].checked, false, "Reappending radios uphold not being checked" );
501
+
502
+ equal( jQuery("<div/>").append( valueObj("option<area/>") )[ 0 ].childNodes.length, 2, "HTML-string with leading text should be processed correctly" );
503
+ };
504
+
505
+ test( "append(String|Element|Array<Element>|jQuery)", function() {
506
+ testAppend( manipulationBareObj );
507
+ });
508
+
509
+ test( "append(Function)", function() {
510
+ testAppend( manipulationFunctionReturningObj );
511
+ });
512
+
513
+ test( "append(param) to object, see #11280", function() {
514
+
515
+ expect( 5 );
516
+
517
+ var object = jQuery( document.createElement("object") ).appendTo( document.body );
518
+
519
+ equal( object.children().length, 0, "object does not start with children" );
520
+
521
+ object.append( jQuery("<param type='wmode' name='foo'>") );
522
+ equal( object.children().length, 1, "appended param" );
523
+ equal( object.children().eq(0).attr("name"), "foo", "param has name=foo" );
524
+
525
+ object = jQuery("<object><param type='baz' name='bar'></object>");
526
+ equal( object.children().length, 1, "object created with child param" );
527
+ equal( object.children().eq(0).attr("name"), "bar", "param has name=bar" );
528
+ });
529
+
530
+ test( "append(Function) with incoming value", function() {
531
+
532
+ expect( 12 );
533
+
534
+ var defaultText, result, select, old, expected;
535
+
536
+ defaultText = "Try them out:";
537
+ old = jQuery("#first").html();
538
+
539
+ result = jQuery("#first").append(function( i, val ) {
540
+ equal( val, old, "Make sure the incoming value is correct." );
541
+ return "<b>buga</b>";
542
+ });
543
+ equal( result.text(), defaultText + "buga", "Check if text appending works" );
544
+
545
+ select = jQuery("#select3");
546
+ old = select.html();
547
+
548
+ equal( select.append(function( i, val ) {
549
+ equal( val, old, "Make sure the incoming value is correct." );
550
+ return "<option value='appendTest'>Append Test</option>";
551
+ }).find("option:last-child").attr("value"), "appendTest", "Appending html options to select element" );
552
+
553
+ QUnit.reset();
554
+ expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
555
+ old = jQuery("#sap").html();
556
+
557
+ jQuery("#sap").append(function( i, val ) {
558
+ equal( val, old, "Make sure the incoming value is correct." );
559
+ return document.getElementById("first");
560
+ });
561
+ equal( jQuery("#sap").text(), expected, "Check for appending of element" );
562
+
563
+ QUnit.reset();
564
+ expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
565
+ old = jQuery("#sap").html();
566
+
567
+ jQuery("#sap").append(function( i, val ) {
568
+ equal( val, old, "Make sure the incoming value is correct." );
569
+ return [ document.getElementById("first"), document.getElementById("yahoo") ];
570
+ });
571
+ equal( jQuery("#sap").text(), expected, "Check for appending of array of elements" );
572
+
573
+ QUnit.reset();
574
+ expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:";
575
+ old = jQuery("#sap").html();
576
+
577
+ jQuery("#sap").append(function( i, val ) {
578
+ equal( val, old, "Make sure the incoming value is correct." );
579
+ return jQuery("#yahoo, #first");
580
+ });
581
+ equal( jQuery("#sap").text(), expected, "Check for appending of jQuery object" );
582
+
583
+ QUnit.reset();
584
+ old = jQuery("#sap").html();
585
+
586
+ jQuery("#sap").append(function( i, val ) {
587
+ equal( val, old, "Make sure the incoming value is correct." );
588
+ return 5;
589
+ });
590
+ ok( jQuery("#sap")[ 0 ].innerHTML.match( /5$/ ), "Check for appending a number" );
591
+
592
+ QUnit.reset();
593
+ });
594
+
595
+ test( "replaceWith on XML document (#9960)", function() {
596
+
597
+ expect( 1 );
598
+
599
+ var newNode,
600
+ xmlDoc1 = jQuery.parseXML("<scxml xmlns='http://www.w3.org/2005/07/scxml' version='1.0'><state x='100' y='100' initial='actions' id='provisioning'></state><state x='100' y='100' id='error'></state><state x='100' y='100' id='finished' final='true'></state></scxml>"),
601
+ xmlDoc2 = jQuery.parseXML("<scxml xmlns='http://www.w3.org/2005/07/scxml' version='1.0'><state id='provisioning3'></state></scxml>"),
602
+ xml1 = jQuery( xmlDoc1 ),
603
+ xml2 = jQuery( xmlDoc2 ),
604
+ scxml1 = jQuery( ":first", xml1 ),
605
+ scxml2 = jQuery( ":first", xml2 );
606
+
607
+ scxml1.replaceWith( scxml2 );
608
+
609
+ newNode = jQuery( ":first>state[id='provisioning3']", xml1 );
610
+
611
+ equal( newNode.length, 1, "ReplaceWith not working on document nodes." );
612
+ });
613
+
614
+ // #12449
615
+ test( "replaceWith([]) where replacing element requires cloning", function () {
616
+ expect(2);
617
+ jQuery("#qunit-fixture").append(
618
+ "<div class='replaceable'></div><div class='replaceable'></div>"
619
+ );
620
+ // replacing set needs to be cloned so it can cover 3 replacements
621
+ jQuery("#qunit-fixture .replaceable").replaceWith(
622
+ jQuery("<span class='replaced'></span><span class='replaced'></span>")
623
+ );
624
+ equal( jQuery("#qunit-fixture").find(".replaceable").length, 0,
625
+ "Make sure replaced elements were removed" );
626
+ equal( jQuery("#qunit-fixture").find(".replaced").length, 4,
627
+ "Make sure replacing elements were cloned" );
628
+ });
629
+
630
+
631
+ test( "append the same fragment with events (Bug #6997, 5566)", function() {
632
+
633
+ var element, clone,
634
+ doExtra = !jQuery.support.noCloneEvent && document["fireEvent"];
635
+
636
+ expect( 2 + ( doExtra ? 1 : 0 ) );
637
+
638
+ stop();
639
+
640
+ // This patch modified the way that cloning occurs in IE; we need to make sure that
641
+ // native event handlers on the original object don't get disturbed when they are
642
+ // modified on the clone
643
+ if ( doExtra ) {
644
+ element = jQuery("div:first").on( "click", function() {
645
+ ok( true, "Event exists on original after being unbound on clone" );
646
+ jQuery( this ).unbind("click");
647
+ });
648
+ clone = element.clone( true ).unbind("click");
649
+ clone[ 0 ].fireEvent("onclick");
650
+ element[ 0 ].fireEvent("onclick");
651
+
652
+ // manually clean up detached elements
653
+ clone.remove();
654
+ }
655
+
656
+ element = jQuery("<a class='test6997'></a>").on( "click", function() {
657
+ ok( true, "Append second element events work" );
658
+ });
659
+
660
+ jQuery("#listWithTabIndex li").append( element )
661
+ .find("a.test6997").eq( 1 ).trigger("click");
662
+
663
+ element = jQuery("<li class='test6997'></li>").on( "click", function() {
664
+ ok( true, "Before second element events work" );
665
+ start();
666
+ });
667
+
668
+ jQuery("#listWithTabIndex li").before( element );
669
+ jQuery("#listWithTabIndex li.test6997").eq( 1 ).trigger("click");
670
+ });
671
+
672
+ test( "append HTML5 sectioning elements (Bug #6485)", function() {
673
+
674
+ expect( 2 );
675
+
676
+ var article, aside;
677
+
678
+ jQuery("#qunit-fixture").append("<article style='font-size:10px'><section><aside>HTML5 elements</aside></section></article>");
679
+
680
+ article = jQuery("article"),
681
+ aside = jQuery("aside");
682
+
683
+ equal( article.get( 0 ).style.fontSize, "10px", "HTML5 elements are styleable" );
684
+ equal( aside.length, 1, "HTML5 elements do not collapse their children" );
685
+ });
686
+
687
+ if ( jQuery.css ) {
688
+ test( "HTML5 Elements inherit styles from style rules (Bug #10501)", function() {
689
+
690
+ expect( 1 );
691
+
692
+ jQuery("#qunit-fixture").append("<article id='article'></article>");
693
+ jQuery("#article").append("<section>This section should have a pink background.</section>");
694
+
695
+ // In IE, the missing background color will claim its value is "transparent"
696
+ notEqual( jQuery("section").css("background-color"), "transparent", "HTML5 elements inherit styles" );
697
+ });
698
+ }
699
+
700
+ test( "html(String) with HTML5 (Bug #6485)", function() {
701
+
702
+ expect( 2 );
703
+
704
+ jQuery("#qunit-fixture").html("<article><section><aside>HTML5 elements</aside></section></article>");
705
+ equal( jQuery("#qunit-fixture").children().children().length, 1, "Make sure HTML5 article elements can hold children. innerHTML shortcut path" );
706
+ equal( jQuery("#qunit-fixture").children().children().children().length, 1, "Make sure nested HTML5 elements can hold children." );
707
+ });
708
+
709
+ test( "IE8 serialization bug", function() {
710
+
711
+ expect( 2 );
712
+ var wrapper = jQuery("<div></div>");
713
+
714
+ wrapper.html("<div></div><article></article>");
715
+ equal( wrapper.children("article").length, 1, "HTML5 elements are insertable with .html()" );
716
+
717
+ wrapper.html("<div></div><link></link>");
718
+ equal( wrapper.children("link").length, 1, "Link elements are insertable with .html()" );
719
+ });
720
+
721
+ test( "html() object element #10324", function() {
722
+
723
+ expect( 1 );
724
+
725
+ var object = jQuery("<object id='object2'><param name='object2test' value='test'></param></object>?").appendTo("#qunit-fixture"),
726
+ clone = object.clone();
727
+
728
+ equal( clone.html(), object.html(), "html() returns correct innerhtml of cloned object elements" );
729
+ });
730
+
731
+ test( "append(xml)", function() {
732
+
733
+ expect( 1 );
734
+
735
+ var xmlDoc, xml1, xml2;
736
+
737
+ function createXMLDoc() {
738
+ // Initialize DOM based upon latest installed MSXML or Netscape
739
+ var elem, n, len,
740
+ aActiveX =
741
+ [ "MSXML6.DomDocument",
742
+ "MSXML3.DomDocument",
743
+ "MSXML2.DomDocument",
744
+ "MSXML.DomDocument",
745
+ "Microsoft.XmlDom" ];
746
+
747
+ if ( document.implementation && "createDocument" in document.implementation ) {
748
+ return document.implementation.createDocument( "", "", null );
749
+ } else {
750
+ // IE
751
+ for ( n = 0, len = aActiveX.length; n < len; n++ ) {
752
+ try {
753
+ elem = new ActiveXObject( aActiveX[ n ] );
754
+ return elem;
755
+ } catch(_) {}
756
+ }
757
+ }
758
+ }
759
+
760
+ xmlDoc = createXMLDoc();
761
+ xml1 = xmlDoc.createElement("head");
762
+ xml2 = xmlDoc.createElement("test");
763
+
764
+ ok( jQuery(xml1).append(xml2), "Append an xml element to another without raising an exception." );
765
+
766
+ });
767
+
768
+ test( "appendTo(String|Element|Array<Element>|jQuery)", function() {
769
+
770
+ expect( 16 );
771
+
772
+ var defaultText, l, expected, num, div;
773
+
774
+ defaultText = "Try them out:";
775
+ jQuery("<b>buga</b>").appendTo("#first");
776
+ equal( jQuery("#first").text(), defaultText + "buga", "Check if text appending works" );
777
+ equal( jQuery("<option value='appendTest'>Append Test</option>").appendTo("#select3").parent().find("option:last-child").attr("value"), "appendTest", "Appending html options to select element" );
778
+
779
+ QUnit.reset();
780
+ l = jQuery("#first").children().length + 2;
781
+ jQuery("<strong>test</strong>");
782
+ jQuery("<strong>test</strong>");
783
+ jQuery([ jQuery("<strong>test</strong>")[ 0 ], jQuery("<strong>test</strong>")[ 0 ] ])
784
+ .appendTo("#first");
785
+ equal( jQuery("#first").children().length, l, "Make sure the elements were inserted." );
786
+ equal( jQuery("#first").children().last()[ 0 ].nodeName.toLowerCase(), "strong", "Verify the last element." );
787
+
788
+ QUnit.reset();
789
+ expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
790
+ jQuery( document.getElementById("first") ).appendTo("#sap");
791
+ equal( jQuery("#sap").text(), expected, "Check for appending of element" );
792
+
793
+ QUnit.reset();
794
+ expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
795
+ jQuery([ document.getElementById("first"), document.getElementById("yahoo") ]).appendTo("#sap");
796
+ equal( jQuery("#sap").text(), expected, "Check for appending of array of elements" );
797
+
798
+ QUnit.reset();
799
+ ok( jQuery(document.createElement("script")).appendTo("body").length, "Make sure a disconnected script can be appended." );
800
+
801
+ QUnit.reset();
802
+ expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:";
803
+ jQuery("#yahoo, #first").appendTo("#sap");
804
+ equal( jQuery("#sap").text(), expected, "Check for appending of jQuery object" );
805
+
806
+ QUnit.reset();
807
+ jQuery("#select1").appendTo("#foo");
808
+ t( "Append select", "#foo select", [ "select1" ] );
809
+
810
+ QUnit.reset();
811
+ div = jQuery("<div/>").on( "click", function() {
812
+ ok( true, "Running a cloned click." );
813
+ });
814
+ div.appendTo("#qunit-fixture, #moretests");
815
+
816
+ jQuery("#qunit-fixture div:last").trigger("click");
817
+ jQuery("#moretests div:last").trigger("click");
818
+
819
+ QUnit.reset();
820
+ div = jQuery("<div/>").appendTo("#qunit-fixture, #moretests");
821
+
822
+ equal( div.length, 2, "appendTo returns the inserted elements" );
823
+
824
+ div.addClass("test");
825
+
826
+ ok( jQuery("#qunit-fixture div:last").hasClass("test"), "appendTo element was modified after the insertion" );
827
+ ok( jQuery("#moretests div:last").hasClass("test"), "appendTo element was modified after the insertion" );
828
+
829
+ QUnit.reset();
830
+
831
+ div = jQuery("<div/>");
832
+ jQuery("<span>a</span><b>b</b>").filter("span").appendTo( div );
833
+
834
+ equal( div.children().length, 1, "Make sure the right number of children were inserted." );
835
+
836
+ div = jQuery("#moretests div");
837
+
838
+ num = jQuery("#qunit-fixture div").length;
839
+ div.remove().appendTo("#qunit-fixture");
840
+
841
+ equal( jQuery("#qunit-fixture div").length, num, "Make sure all the removed divs were inserted." );
842
+ });
843
+
844
+ var testPrepend = function( val ) {
845
+
846
+ expect( 6 );
847
+
848
+ var defaultText, result, expected;
849
+
850
+ defaultText = "Try them out:";
851
+ result = jQuery("#first").prepend( val("<b>buga</b>") );
852
+
853
+ equal( result.text(), "buga" + defaultText, "Check if text prepending works" );
854
+ equal( jQuery("#select3").prepend( val("<option value='prependTest'>Prepend Test</option>" ) ).find("option:first-child").attr("value"), "prependTest", "Prepending html options to select element" );
855
+
856
+ QUnit.reset();
857
+ expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
858
+ jQuery("#sap").prepend( val(document.getElementById("first")) );
859
+ equal( jQuery("#sap").text(), expected, "Check for prepending of element" );
860
+
861
+ QUnit.reset();
862
+ expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
863
+ jQuery("#sap").prepend( val([ document.getElementById("first"), document.getElementById("yahoo") ]) );
864
+ equal( jQuery("#sap").text(), expected, "Check for prepending of array of elements" );
865
+
866
+ QUnit.reset();
867
+ expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog";
868
+ jQuery("#sap").prepend( val(jQuery("#yahoo, #first")) );
869
+ equal( jQuery("#sap").text(), expected, "Check for prepending of jQuery object" );
870
+
871
+ QUnit.reset();
872
+ expected = "Try them out:GoogleYahooThis link has class=\"blog\": Simon Willison's Weblog";
873
+ jQuery("#sap").prepend( val([ jQuery("#first"), jQuery("#yahoo, #google") ]) );
874
+ equal( jQuery("#sap").text(), expected, "Check for prepending of array of jQuery objects" );
875
+ };
876
+
877
+ test( "prepend(String|Element|Array<Element>|jQuery)", function() {
878
+ testPrepend( manipulationBareObj );
879
+ });
880
+
881
+ test( "prepend(Function)", function() {
882
+ testPrepend( manipulationFunctionReturningObj );
883
+ });
884
+
885
+ test( "prepend(Function) with incoming value", function() {
886
+
887
+ expect( 10 );
888
+
889
+ var defaultText, old, result, expected;
890
+
891
+ defaultText = "Try them out:";
892
+ old = jQuery("#first").html();
893
+ result = jQuery("#first").prepend(function( i, val ) {
894
+ equal( val, old, "Make sure the incoming value is correct." );
895
+ return "<b>buga</b>";
896
+ });
897
+
898
+ equal( result.text(), "buga" + defaultText, "Check if text prepending works" );
899
+
900
+ old = jQuery("#select3").html();
901
+
902
+ equal( jQuery("#select3").prepend(function( i, val ) {
903
+ equal( val, old, "Make sure the incoming value is correct." );
904
+ return "<option value='prependTest'>Prepend Test</option>";
905
+ }).find("option:first-child").attr("value"), "prependTest", "Prepending html options to select element" );
906
+
907
+ QUnit.reset();
908
+ expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
909
+ old = jQuery("#sap").html();
910
+
911
+ jQuery("#sap").prepend(function( i, val ) {
912
+ equal( val, old, "Make sure the incoming value is correct." );
913
+ return document.getElementById("first");
914
+ });
915
+
916
+ equal( jQuery("#sap").text(), expected, "Check for prepending of element" );
917
+
918
+ QUnit.reset();
919
+ expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
920
+ old = jQuery("#sap").html();
921
+
922
+ jQuery("#sap").prepend(function( i, val ) {
923
+ equal( val, old, "Make sure the incoming value is correct." );
924
+ return [ document.getElementById("first"), document.getElementById("yahoo") ];
925
+ });
926
+
927
+ equal( jQuery("#sap").text(), expected, "Check for prepending of array of elements" );
928
+
929
+ QUnit.reset();
930
+ expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog";
931
+ old = jQuery("#sap").html();
932
+
933
+ jQuery("#sap").prepend(function( i, val ) {
934
+ equal( val, old, "Make sure the incoming value is correct." );
935
+ return jQuery("#yahoo, #first");
936
+ });
937
+
938
+ equal( jQuery("#sap").text(), expected, "Check for prepending of jQuery object" );
939
+ });
940
+
941
+ test( "prependTo(String|Element|Array<Element>|jQuery)", function() {
942
+
943
+ expect( 6 );
944
+
945
+ var defaultText, expected;
946
+
947
+ defaultText = "Try them out:";
948
+ jQuery("<b>buga</b>").prependTo("#first");
949
+ equal( jQuery("#first").text(), "buga" + defaultText, "Check if text prepending works" );
950
+ equal( jQuery("<option value='prependTest'>Prepend Test</option>").prependTo("#select3").parent().find("option:first-child").attr("value"), "prependTest", "Prepending html options to select element" );
951
+
952
+ QUnit.reset();
953
+ expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
954
+ jQuery( document.getElementById("first") ).prependTo("#sap");
955
+ equal( jQuery("#sap").text(), expected, "Check for prepending of element" );
956
+
957
+ QUnit.reset();
958
+ expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
959
+ jQuery( [ document.getElementById("first"), document.getElementById("yahoo") ] ).prependTo("#sap");
960
+ equal( jQuery("#sap").text(), expected, "Check for prepending of array of elements" );
961
+
962
+ QUnit.reset();
963
+ expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog";
964
+ jQuery("#yahoo, #first").prependTo("#sap");
965
+ equal( jQuery("#sap").text(), expected, "Check for prepending of jQuery object" );
966
+
967
+ QUnit.reset();
968
+ jQuery("<select id='prependSelect1'></select>").prependTo("form:last");
969
+ jQuery("<select id='prependSelect2'><option>Test</option></select>").prependTo("form:last");
970
+
971
+ t( "Prepend Select", "#prependSelect2, #prependSelect1", [ "prependSelect2", "prependSelect1" ] );
972
+ });
973
+
974
+ var testBefore = function( val ) {
975
+
976
+ expect( 7 );
977
+
978
+ var expected, set;
979
+
980
+ expected = "This is a normal link: bugaYahoo";
981
+ jQuery("#yahoo").before( val("<b>buga</b>") );
982
+ equal( jQuery("#en").text(), expected, "Insert String before" );
983
+
984
+ QUnit.reset();
985
+ expected = "This is a normal link: Try them out:Yahoo";
986
+ jQuery("#yahoo").before( val(document.getElementById("first")) );
987
+ equal( jQuery("#en").text(), expected, "Insert element before" );
988
+
989
+ QUnit.reset();
990
+ expected = "This is a normal link: Try them out:diveintomarkYahoo";
991
+ jQuery("#yahoo").before( val([ document.getElementById("first"), document.getElementById("mark") ]) );
992
+ equal( jQuery("#en").text(), expected, "Insert array of elements before" );
993
+
994
+ QUnit.reset();
995
+ expected = "This is a normal link: diveintomarkTry them out:Yahoo";
996
+ jQuery("#yahoo").before( val(jQuery("#mark, #first")) );
997
+ equal( jQuery("#en").text(), expected, "Insert jQuery before" );
998
+
999
+ QUnit.reset();
1000
+ expected = "This is a normal link: Try them out:GooglediveintomarkYahoo";
1001
+ jQuery("#yahoo").before( val([ jQuery("#first"), jQuery("#mark, #google") ]) );
1002
+ equal( jQuery("#en").text(), expected, "Insert array of jQuery objects before" );
1003
+
1004
+ set = jQuery("<div/>").before("<span>test</span>");
1005
+ equal( set[ 0 ].nodeName.toLowerCase(), "div", "Insert before a disconnected node should be a no-op" );
1006
+ equal( set.length, 1, "Insert the element before the disconnected node. should be a no-op" );
1007
+ };
1008
+
1009
+ test( "before(String|Element|Array<Element>|jQuery)", function() {
1010
+ testBefore( manipulationBareObj );
1011
+ });
1012
+
1013
+ test( "before(Function)", function() {
1014
+ testBefore( manipulationFunctionReturningObj );
1015
+ });
1016
+
1017
+ test( "before and after w/ empty object (#10812)", function() {
1018
+
1019
+ expect( 1 );
1020
+
1021
+ var res;
1022
+
1023
+ res = jQuery( "#notInTheDocument" ).before( "(" ).after( ")" );
1024
+ equal( res.length, 0, "didn't choke on empty object" );
1025
+ });
1026
+
1027
+ test( "before and after on disconnected node (#10517)", function() {
1028
+
1029
+ expect( 6 );
1030
+
1031
+ var expectedBefore = "This is a normal link: bugaYahoo",
1032
+ expectedAfter = "This is a normal link: Yahoobuga";
1033
+
1034
+ equal( jQuery("<input type='checkbox'/>").before("<div/>").length, 1, "before() on disconnected node is no-op" );
1035
+ equal( jQuery("<input type='checkbox'/>").after("<div/>").length, 1, "after() on disconnected node is no-op" );
1036
+
1037
+ QUnit.reset();
1038
+ jQuery("#yahoo").add("<span/>").before("<b>buga</b>");
1039
+ equal( jQuery("#en").text(), expectedBefore, "Insert String before with disconnected node last" );
1040
+
1041
+ QUnit.reset();
1042
+ jQuery("<span/>").add("#yahoo").before("<b>buga</b>");
1043
+ equal( jQuery("#en").text(), expectedBefore, "Insert String before with disconnected node first" );
1044
+
1045
+ QUnit.reset();
1046
+ jQuery("#yahoo").add("<span/>").after("<b>buga</b>");
1047
+ equal( jQuery("#en").text(), expectedAfter, "Insert String after with disconnected node last" );
1048
+
1049
+ QUnit.reset();
1050
+ jQuery("<span/>").add("#yahoo").after("<b>buga</b>");
1051
+ equal( jQuery("#en").text(), expectedAfter, "Insert String after with disconnected node first" );
1052
+ });
1053
+
1054
+ test( "insertBefore(String|Element|Array<Element>|jQuery)", function() {
1055
+
1056
+ expect( 4 );
1057
+
1058
+ var expected;
1059
+
1060
+ expected = "This is a normal link: bugaYahoo";
1061
+ jQuery("<b>buga</b>").insertBefore("#yahoo");
1062
+ equal( jQuery("#en").text(), expected, "Insert String before" );
1063
+
1064
+ QUnit.reset();
1065
+ expected = "This is a normal link: Try them out:Yahoo";
1066
+ jQuery( document.getElementById("first") ).insertBefore("#yahoo");
1067
+ equal( jQuery("#en").text(), expected, "Insert element before" );
1068
+
1069
+ QUnit.reset();
1070
+ expected = "This is a normal link: Try them out:diveintomarkYahoo";
1071
+ jQuery( [ document.getElementById("first"), document.getElementById("mark") ] ).insertBefore("#yahoo");
1072
+ equal( jQuery("#en").text(), expected, "Insert array of elements before" );
1073
+
1074
+ QUnit.reset();
1075
+ expected = "This is a normal link: diveintomarkTry them out:Yahoo";
1076
+ jQuery("#mark, #first").insertBefore("#yahoo");
1077
+ equal( jQuery("#en").text(), expected, "Insert jQuery before" );
1078
+ });
1079
+
1080
+ var testAfter = function( val ) {
1081
+
1082
+ expect( 7 );
1083
+
1084
+ var set, expected;
1085
+
1086
+ expected = "This is a normal link: Yahoobuga";
1087
+ jQuery("#yahoo").after( val("<b>buga</b>") );
1088
+ equal( jQuery("#en").text(), expected, "Insert String after" );
1089
+
1090
+ QUnit.reset();
1091
+ expected = "This is a normal link: YahooTry them out:";
1092
+ jQuery("#yahoo").after( val(document.getElementById("first")) );
1093
+ equal( jQuery("#en").text(), expected, "Insert element after" );
1094
+
1095
+ QUnit.reset();
1096
+ expected = "This is a normal link: YahooTry them out:diveintomark";
1097
+ jQuery("#yahoo").after( val([ document.getElementById("first"), document.getElementById("mark") ]) );
1098
+ equal( jQuery("#en").text(), expected, "Insert array of elements after" );
1099
+
1100
+ QUnit.reset();
1101
+ expected = "This is a normal link: YahoodiveintomarkTry them out:";
1102
+ jQuery("#yahoo").after(val( jQuery("#mark, #first") ));
1103
+ equal( jQuery("#en").text(), expected, "Insert jQuery after" );
1104
+
1105
+ QUnit.reset();
1106
+ expected = "This is a normal link: YahooTry them out:Googlediveintomark";
1107
+ jQuery("#yahoo").after( val([ jQuery("#first"), jQuery("#mark, #google") ]) );
1108
+ equal( jQuery("#en").text(), expected, "Insert array of jQuery objects after" );
1109
+
1110
+ set = jQuery("<div/>").before("<span>test</span>");
1111
+ equal( set[ 0 ].nodeName.toLowerCase(), "div", "Insert after a disconnected node should be a no-op" );
1112
+ equal( set.length, 1, "Insert the element after the disconnected node should be a no-op" );
1113
+ };
1114
+
1115
+ test( "after(String|Element|Array<Element>|jQuery)", function() {
1116
+ testAfter( manipulationBareObj );
1117
+ });
1118
+
1119
+ test( "after(Function)", function() {
1120
+ testAfter( manipulationFunctionReturningObj );
1121
+ });
1122
+
1123
+ test( "insertAfter(String|Element|Array<Element>|jQuery)", function() {
1124
+
1125
+ expect( 4 ) ;
1126
+
1127
+ var expected;
1128
+
1129
+ expected = "This is a normal link: Yahoobuga";
1130
+ jQuery("<b>buga</b>").insertAfter("#yahoo");
1131
+ equal( jQuery("#en").text(), expected, "Insert String after" );
1132
+
1133
+ QUnit.reset();
1134
+ expected = "This is a normal link: YahooTry them out:";
1135
+ jQuery( document.getElementById("first") ).insertAfter("#yahoo");
1136
+ equal( jQuery("#en").text(), expected, "Insert element after" );
1137
+
1138
+ QUnit.reset();
1139
+ expected = "This is a normal link: YahooTry them out:diveintomark";
1140
+ jQuery( [ document.getElementById("first"), document.getElementById("mark") ] ).insertAfter("#yahoo");
1141
+ equal( jQuery("#en").text(), expected, "Insert array of elements after" );
1142
+
1143
+ QUnit.reset();
1144
+ expected = "This is a normal link: YahoodiveintomarkTry them out:";
1145
+ jQuery("#mark, #first").insertAfter("#yahoo");
1146
+ equal( jQuery("#en").text(), expected, "Insert jQuery after" );
1147
+ });
1148
+
1149
+ var testReplaceWith = function( val ) {
1150
+
1151
+ var tmp, y, child, child2, set, non_existent, $div,
1152
+ expected = 23;
1153
+
1154
+ expect( expected );
1155
+
1156
+ jQuery("#yahoo").replaceWith( val("<b id='replace'>buga</b>") );
1157
+ ok( jQuery("#replace")[ 0 ], "Replace element with element from string" );
1158
+ ok( !jQuery("#yahoo")[ 0 ], "Verify that original element is gone, after string" );
1159
+
1160
+ jQuery("#anchor2").replaceWith( val(document.getElementById("first")) );
1161
+ ok( jQuery("#first")[ 0 ], "Replace element with element" );
1162
+ ok( !jQuery("#anchor2")[ 0 ], "Verify that original element is gone, after element" );
1163
+
1164
+ jQuery("#qunit-fixture").append("<div id='bar'><div id='baz'></div></div>");
1165
+ jQuery("#baz").replaceWith( val("Baz") );
1166
+ equal( jQuery("#bar").text(),"Baz", "Replace element with text" );
1167
+ ok( !jQuery("#baz")[ 0 ], "Verify that original element is gone, after element" );
1168
+
1169
+ jQuery("#google").replaceWith( val([ document.getElementById("first"), document.getElementById("mark") ]) );
1170
+ ok( jQuery("#first")[ 0 ], "Replace element with array of elements" );
1171
+ ok( jQuery("#mark")[ 0 ], "Replace element with array of elements" );
1172
+ ok( !jQuery("#google")[ 0 ], "Verify that original element is gone, after array of elements" );
1173
+
1174
+ jQuery("#groups").replaceWith( val(jQuery("#mark, #first")) );
1175
+ ok( jQuery("#first")[ 0 ], "Replace element with set of elements" );
1176
+ ok( jQuery("#mark")[ 0 ], "Replace element with set of elements" );
1177
+ ok( !jQuery("#groups")[ 0 ], "Verify that original element is gone, after set of elements" );
1178
+
1179
+ tmp = jQuery("<b>content</b>")[0];
1180
+ jQuery("#anchor1").contents().replaceWith( val(tmp) );
1181
+ deepEqual( jQuery("#anchor1").contents().get(), [ tmp ], "Replace text node with element" );
1182
+
1183
+
1184
+ tmp = jQuery("<div/>").appendTo("#qunit-fixture").on( "click", function() {
1185
+ ok( true, "Newly bound click run." );
1186
+ });
1187
+ y = jQuery("<div/>").appendTo("#qunit-fixture").on( "click", function() {
1188
+ ok( false, "Previously bound click run." );
1189
+ });
1190
+ child = y.append("<b>test</b>").find("b").on( "click", function() {
1191
+ ok( true, "Child bound click run." );
1192
+ return false;
1193
+ });
1194
+
1195
+ y.replaceWith( val(tmp) );
1196
+
1197
+ tmp.trigger("click");
1198
+ y.trigger("click"); // Shouldn't be run
1199
+ child.trigger("click"); // Shouldn't be run
1200
+
1201
+
1202
+ y = jQuery("<div/>").appendTo("#qunit-fixture").on( "click", function() {
1203
+ ok( false, "Previously bound click run." );
1204
+ });
1205
+ child2 = y.append("<u>test</u>").find("u").on( "click", function() {
1206
+ ok( true, "Child 2 bound click run." );
1207
+ return false;
1208
+ });
1209
+
1210
+ y.replaceWith( val(child2) );
1211
+
1212
+ child2.trigger("click");
1213
+
1214
+
1215
+ set = jQuery("<div/>").replaceWith( val("<span>test</span>") );
1216
+ equal( set[0].nodeName.toLowerCase(), "div", "No effect on a disconnected node." );
1217
+ equal( set.length, 1, "No effect on a disconnected node." );
1218
+ equal( set[0].childNodes.length, 0, "No effect on a disconnected node." );
1219
+
1220
+
1221
+ non_existent = jQuery("#does-not-exist").replaceWith( val("<b>should not throw an error</b>") );
1222
+ equal( non_existent.length, 0, "Length of non existent element." );
1223
+
1224
+ $div = jQuery("<div class='replacewith'></div>").appendTo("#qunit-fixture");
1225
+ $div.replaceWith( val("<div class='replacewith'></div><script>" +
1226
+ "equal( jQuery('.replacewith').length, 1, 'Check number of elements in page.' );" +
1227
+ "</script>") );
1228
+
1229
+ jQuery("#qunit-fixture").append("<div id='replaceWith'></div>");
1230
+ equal( jQuery("#qunit-fixture").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." );
1231
+ jQuery("#replaceWith").replaceWith( val("<div id='replaceWith'></div>") );
1232
+ equal( jQuery("#qunit-fixture").find("div[id=replaceWith]").length, 1, "Make sure only one div exists after replacement." );
1233
+ jQuery("#replaceWith").replaceWith( val("<div id='replaceWith'></div>") );
1234
+ equal( jQuery("#qunit-fixture").find("div[id=replaceWith]").length, 1, "Make sure only one div exists after subsequent replacement." );
1235
+
1236
+ return expected;
1237
+ };
1238
+
1239
+ test( "replaceWith(String|Element|Array<Element>|jQuery)", function() {
1240
+ testReplaceWith( manipulationBareObj );
1241
+ });
1242
+
1243
+ test( "replaceWith(Function)", function() {
1244
+ expect( testReplaceWith(manipulationFunctionReturningObj) + 1 );
1245
+
1246
+ var y = jQuery("#foo")[ 0 ];
1247
+
1248
+ jQuery( y ).replaceWith(function() {
1249
+ equal( this, y, "Make sure the context is coming in correctly." );
1250
+ });
1251
+ });
1252
+
1253
+ test( "replaceWith(string) for more than one element", function() {
1254
+
1255
+ expect( 3 );
1256
+
1257
+ equal( jQuery("#foo p").length, 3, "ensuring that test data has not changed" );
1258
+
1259
+ jQuery("#foo p").replaceWith("<span>bar</span>");
1260
+ equal(jQuery("#foo span").length, 3, "verify that all the three original element have been replaced");
1261
+ equal(jQuery("#foo p").length, 0, "verify that all the three original element have been replaced");
1262
+ });
1263
+
1264
+ test( "replaceAll(String|Element|Array<Element>|jQuery)", function() {
1265
+
1266
+ expect( 10 );
1267
+
1268
+ jQuery("<b id='replace'>buga</b>").replaceAll("#yahoo");
1269
+ ok( jQuery("#replace")[ 0 ], "Replace element with string" );
1270
+ ok( !jQuery("#yahoo")[ 0 ], "Verify that original element is gone, after string" );
1271
+
1272
+ QUnit.reset();
1273
+ jQuery( document.getElementById("first") ).replaceAll("#yahoo");
1274
+ ok( jQuery("#first")[ 0 ], "Replace element with element" );
1275
+ ok( !jQuery("#yahoo")[ 0 ], "Verify that original element is gone, after element" );
1276
+
1277
+ QUnit.reset();
1278
+ jQuery( [ document.getElementById("first"), document.getElementById("mark") ] ).replaceAll("#yahoo");
1279
+ ok( jQuery("#first")[ 0 ], "Replace element with array of elements" );
1280
+ ok( jQuery("#mark")[ 0 ], "Replace element with array of elements" );
1281
+ ok( !jQuery("#yahoo")[ 0 ], "Verify that original element is gone, after array of elements" );
1282
+
1283
+ QUnit.reset();
1284
+ jQuery("#mark, #first").replaceAll("#yahoo");
1285
+ ok( jQuery("#first")[ 0 ], "Replace element with set of elements" );
1286
+ ok( jQuery("#mark")[ 0 ], "Replace element with set of elements" );
1287
+ ok( !jQuery("#yahoo")[ 0 ], "Verify that original element is gone, after set of elements" );
1288
+ });
1289
+
1290
+ test( "jQuery.clone() (#8017)", function() {
1291
+
1292
+ expect( 2 );
1293
+
1294
+ ok( jQuery.clone && jQuery.isFunction( jQuery.clone ) , "jQuery.clone() utility exists and is a function.");
1295
+
1296
+ var main = jQuery("#qunit-fixture")[ 0 ],
1297
+ clone = jQuery.clone( main );
1298
+
1299
+ equal( main.childNodes.length, clone.childNodes.length, "Simple child length to ensure a large dom tree copies correctly" );
1300
+ });
1301
+
1302
+ test( "append to multiple elements (#8070)", function() {
1303
+
1304
+ expect( 2 );
1305
+
1306
+ var selects = jQuery("<select class='test8070'></select><select class='test8070'></select>").appendTo("#qunit-fixture");
1307
+ selects.append("<OPTION>1</OPTION><OPTION>2</OPTION>");
1308
+
1309
+ equal( selects[ 0 ].childNodes.length, 2, "First select got two nodes" );
1310
+ equal( selects[ 1 ].childNodes.length, 2, "Second select got two nodes" );
1311
+ });
1312
+
1313
+ test( "clone()", function() {
1314
+
1315
+ expect( 45 );
1316
+
1317
+ var div, clone, form, body;
1318
+
1319
+ equal( jQuery("#en").text(), "This is a normal link: Yahoo", "Assert text for #en" );
1320
+ equal( jQuery("#first").append( jQuery("#yahoo").clone() ).text(), "Try them out:Yahoo", "Check for clone" );
1321
+ equal( jQuery("#en").text(), "This is a normal link: Yahoo", "Reassert text for #en" );
1322
+
1323
+ jQuery.each( "table thead tbody tfoot tr td div button ul ol li select option textarea iframe".split(" "), function( i, nodeName ) {
1324
+ equal( jQuery( "<" + nodeName + "/>" ).clone()[ 0 ].nodeName.toLowerCase(), nodeName, "Clone a " + nodeName );
1325
+ });
1326
+ equal( jQuery("<input type='checkbox' />").clone()[ 0 ].nodeName.toLowerCase(), "input", "Clone a <input type='checkbox' />" );
1327
+
1328
+ // Check cloning non-elements
1329
+ equal( jQuery("#nonnodes").contents().clone().length, 3, "Check node,textnode,comment clone works (some browsers delete comments on clone)" );
1330
+
1331
+ // Verify that clones of clones can keep event listeners
1332
+ div = jQuery("<div><ul><li>test</li></ul></div>").on( "click", function() {
1333
+ ok( true, "Bound event still exists." );
1334
+ });
1335
+ clone = div.clone( true ); div.remove();
1336
+ div = clone.clone( true ); clone.remove();
1337
+
1338
+ equal( div.length, 1, "One element cloned" );
1339
+ equal( div[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
1340
+ div.trigger("click");
1341
+
1342
+ // Manually clean up detached elements
1343
+ div.remove();
1344
+
1345
+ // Verify that cloned children can keep event listeners
1346
+ div = jQuery("<div/>").append([ document.createElement("table"), document.createElement("table") ]);
1347
+ div.find("table").on( "click", function() {
1348
+ ok( true, "Bound event still exists." );
1349
+ });
1350
+
1351
+ clone = div.clone( true );
1352
+ equal( clone.length, 1, "One element cloned" );
1353
+ equal( clone[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
1354
+ clone.find("table").trigger("click");
1355
+
1356
+ // Manually clean up detached elements
1357
+ div.remove();
1358
+ clone.remove();
1359
+
1360
+ // Make sure that doing .clone() doesn't clone event listeners
1361
+ div = jQuery("<div><ul><li>test</li></ul></div>").on( "click", function() {
1362
+ ok( false, "Bound event still exists after .clone()." );
1363
+ });
1364
+ clone = div.clone();
1365
+
1366
+ clone.trigger("click");
1367
+
1368
+ // Manually clean up detached elements
1369
+ clone.remove();
1370
+ div.remove();
1371
+
1372
+ // Test both html() and clone() for <embed> and <object> types
1373
+ div = jQuery("<div/>").html("<embed height='355' width='425' src='http://www.youtube.com/v/3KANI2dpXLw&amp;hl=en'></embed>");
1374
+
1375
+ clone = div.clone( true );
1376
+ equal( clone.length, 1, "One element cloned" );
1377
+ equal( clone.html(), div.html(), "Element contents cloned" );
1378
+ equal( clone[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
1379
+
1380
+ // this is technically an invalid object, but because of the special
1381
+ // classid instantiation it is the only kind that IE has trouble with,
1382
+ // so let's test with it too.
1383
+ div = jQuery("<div/>").html("<object height='355' width='425' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'> <param name='movie' value='http://www.youtube.com/v/3KANI2dpXLw&amp;hl=en'> <param name='wmode' value='transparent'> </object>");
1384
+
1385
+ clone = div.clone( true );
1386
+ equal( clone.length, 1, "One element cloned" );
1387
+ equal( clone[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
1388
+ div = div.find("object");
1389
+ clone = clone.find("object");
1390
+ // oldIE adds extra attributes and <param> elements, so just test for existence of the defined set
1391
+ jQuery.each( [ "height", "width", "classid" ], function( i, attr ) {
1392
+ equal( clone.attr( attr ), div.attr( attr ), "<object> attribute cloned: " + attr );
1393
+ } );
1394
+ (function() {
1395
+ var params = {};
1396
+
1397
+ clone.find("param").each(function( index, param ) {
1398
+ params[ param.attributes.name.nodeValue.toLowerCase() ] =
1399
+ param.attributes.value.nodeValue.toLowerCase();
1400
+ });
1401
+
1402
+ div.find("param").each(function( index, param ) {
1403
+ var key = param.attributes.name.nodeValue.toLowerCase();
1404
+ equal( params[ key ], param.attributes.value.nodeValue.toLowerCase(), "<param> cloned: " + key );
1405
+ });
1406
+ })();
1407
+
1408
+ // and here's a valid one.
1409
+ div = jQuery("<div/>").html("<object height='355' width='425' type='application/x-shockwave-flash' data='http://www.youtube.com/v/3KANI2dpXLw&amp;hl=en'> <param name='movie' value='http://www.youtube.com/v/3KANI2dpXLw&amp;hl=en'> <param name='wmode' value='transparent'> </object>");
1410
+
1411
+ clone = div.clone(true);
1412
+ equal( clone.length, 1, "One element cloned" );
1413
+ equal( clone.html(), div.html(), "Element contents cloned" );
1414
+ equal( clone[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
1415
+
1416
+ div = jQuery("<div/>").data({ "a": true });
1417
+ clone = div.clone( true );
1418
+ equal( clone.data("a"), true, "Data cloned." );
1419
+ clone.data( "a", false );
1420
+ equal( clone.data("a"), false, "Ensure cloned element data object was correctly modified" );
1421
+ equal( div.data("a"), true, "Ensure cloned element data object is copied, not referenced" );
1422
+
1423
+ // manually clean up detached elements
1424
+ div.remove();
1425
+ clone.remove();
1426
+
1427
+ form = document.createElement("form");
1428
+ form.action = "/test/";
1429
+
1430
+ div = document.createElement("div");
1431
+ div.appendChild( document.createTextNode("test") );
1432
+ form.appendChild( div );
1433
+
1434
+ equal( jQuery(form).clone().children().length, 1, "Make sure we just get the form back." );
1435
+
1436
+ body = jQuery("body").clone();
1437
+ equal( body.children()[ 0 ].id, "qunit", "Make sure cloning body works" );
1438
+ body.remove();
1439
+ });
1440
+
1441
+ test( "clone(script type=non-javascript) (#11359)", function() {
1442
+
1443
+ expect( 3 );
1444
+
1445
+ var src = jQuery("<script type='text/filler'>Lorem ipsum dolor sit amet</script><q><script type='text/filler'>consectetur adipiscing elit</script></q>"),
1446
+ dest = src.clone();
1447
+
1448
+ equal( dest[ 0 ].text, "Lorem ipsum dolor sit amet", "Cloning preserves script text" );
1449
+ equal( dest.last().html(), src.last().html(), "Cloning preserves nested script text" );
1450
+ ok( /^\s*<scr.pt\s+type=['"]?text\/filler['"]?\s*>consectetur adipiscing elit<\/scr.pt>\s*$/i.test( dest.last().html() ), "Cloning preserves nested script text" );
1451
+ dest.remove();
1452
+ });
1453
+
1454
+ test( "clone(form element) (Bug #3879, #6655)", function() {
1455
+
1456
+ expect( 5 );
1457
+
1458
+ var clone,
1459
+ element = jQuery("<select><option>Foo</option><option selected>Bar</option></select>");
1460
+
1461
+ equal( element.clone().find("option:selected").val(), element.find("option:selected").val(), "Selected option cloned correctly" );
1462
+
1463
+ element = jQuery("<input type='checkbox' value='foo'>").attr( "checked", "checked" );
1464
+ clone = element.clone();
1465
+
1466
+ equal( clone.is(":checked"), element.is(":checked"), "Checked input cloned correctly" );
1467
+ equal( clone[ 0 ].defaultValue, "foo", "Checked input defaultValue cloned correctly" );
1468
+
1469
+ // defaultChecked also gets set now due to setAttribute in attr, is this check still valid?
1470
+ // equal( clone[0].defaultChecked, !jQuery.support.noCloneChecked, "Checked input defaultChecked cloned correctly" );
1471
+
1472
+ element = jQuery("<input type='text' value='foo'>");
1473
+ clone = element.clone();
1474
+ equal( clone[ 0 ].defaultValue, "foo", "Text input defaultValue cloned correctly" );
1475
+
1476
+ element = jQuery("<textarea>foo</textarea>");
1477
+ clone = element.clone();
1478
+ equal( clone[ 0 ].defaultValue, "foo", "Textarea defaultValue cloned correctly" );
1479
+ });
1480
+
1481
+ test( "clone(multiple selected options) (Bug #8129)", function() {
1482
+
1483
+ expect( 1 );
1484
+
1485
+ var element = jQuery("<select><option>Foo</option><option selected>Bar</option><option selected>Baz</option></select>");
1486
+
1487
+ equal( element.clone().find("option:selected").length, element.find("option:selected").length, "Multiple selected options cloned correctly" );
1488
+
1489
+ });
1490
+
1491
+ test( "clone() on XML nodes", function() {
1492
+
1493
+ expect( 2 );
1494
+
1495
+ var xml = createDashboardXML(),
1496
+ root = jQuery(xml.documentElement).clone(),
1497
+ origTab = jQuery("tab", xml).eq( 0 ),
1498
+ cloneTab = jQuery("tab", root).eq( 0 );
1499
+
1500
+ origTab.text("origval");
1501
+ cloneTab.text("cloneval");
1502
+ equal( origTab.text(), "origval", "Check original XML node was correctly set" );
1503
+ equal( cloneTab.text(), "cloneval", "Check cloned XML node was correctly set" );
1504
+ });
1505
+
1506
+ test( "clone() on local XML nodes with html5 nodename", function() {
1507
+
1508
+ expect( 2 );
1509
+
1510
+ var $xmlDoc = jQuery( jQuery.parseXML( "<root><meter /></root>" ) ),
1511
+ $meter = $xmlDoc.find( "meter" ).clone();
1512
+
1513
+ equal( $meter[ 0 ].nodeName, "meter", "Check if nodeName was not changed due to cloning" );
1514
+ equal( $meter[ 0 ].nodeType, 1, "Check if nodeType is not changed due to cloning" );
1515
+ });
1516
+
1517
+ test( "html(undefined)", function() {
1518
+
1519
+ expect( 1 );
1520
+
1521
+ equal( jQuery("#foo").html("<i>test</i>").html(undefined).html().toLowerCase(), "<i>test</i>", ".html(undefined) is chainable (#5571)" );
1522
+ });
1523
+
1524
+ test( "html() on empty set", function() {
1525
+
1526
+ expect( 1 );
1527
+
1528
+ strictEqual( jQuery().html(), undefined, ".html() returns undefined for empty sets (#11962)" );
1529
+ });
1530
+
1531
+ var childNodeNames = function( node ) {
1532
+ return jQuery.map( node.childNodes, function( child ) {
1533
+ return child.nodeName.toUpperCase();
1534
+ }).join(" ");
1535
+ };
1536
+
1537
+ var testHtml = function( valueObj ) {
1538
+ expect( 37 );
1539
+
1540
+ var actual, expected, tmp,
1541
+ div = jQuery("<div></div>"),
1542
+ fixture = jQuery("#qunit-fixture");
1543
+
1544
+ div.html( valueObj("<div id='parent_1'><div id='child_1'/></div><div id='parent_2'/>") );
1545
+ equal( div.children().length, 2, "Found children" );
1546
+ equal( div.children().children().length, 1, "Found grandchild" );
1547
+
1548
+ actual = []; expected = [];
1549
+ tmp = jQuery("<map/>").html( valueObj("<area alt='area'/>") ).each(function() {
1550
+ expected.push("AREA");
1551
+ actual.push( childNodeNames( this ) );
1552
+ });
1553
+ equal( expected.length, 1, "Expecting one parent" );
1554
+ deepEqual( actual, expected, "Found the inserted area element" );
1555
+
1556
+ equal( div.html(valueObj(5)).html(), "5", "Setting a number as html" );
1557
+ equal( div.html(valueObj(0)).html(), "0", "Setting a zero as html" );
1558
+
1559
+ div.html( valueObj("&#160;&amp;") );
1560
+ equal(
1561
+ div[ 0 ].innerHTML.replace( /\xA0/, "&nbsp;" ),
1562
+ "&nbsp;&amp;",
1563
+ "Entities are passed through correctly"
1564
+ );
1565
+
1566
+ tmp = "&lt;div&gt;hello1&lt;/div&gt;";
1567
+ equal( div.html(valueObj(tmp) ).html().replace( />/g, "&gt;" ), tmp, "Escaped html" );
1568
+ tmp = "x" + tmp;
1569
+ equal( div.html(valueObj( tmp )).html().replace( />/g, "&gt;" ), tmp, "Escaped html, leading x" );
1570
+ tmp = " " + tmp.slice( 1 );
1571
+ equal( div.html(valueObj( tmp )).html().replace( />/g, "&gt;" ), tmp, "Escaped html, leading space" );
1572
+
1573
+ actual = []; expected = []; tmp = {};
1574
+ jQuery("#nonnodes").contents().html( valueObj("<b>bold</b>") ).each(function() {
1575
+ var html = jQuery( this ).html();
1576
+ tmp[ this.nodeType ] = true;
1577
+ expected.push( this.nodeType === 1 ? "<b>bold</b>" : undefined );
1578
+ actual.push( html ? html.toLowerCase() : html );
1579
+ });
1580
+ deepEqual( actual, expected, "Set containing element, text node, comment" );
1581
+ ok( tmp[ 1 ], "element" );
1582
+ ok( tmp[ 3 ], "text node" );
1583
+ ok( tmp[ 8 ], "comment" );
1584
+
1585
+ actual = []; expected = [];
1586
+ fixture.find("> div").html( valueObj("<b>test</b>") ).each(function() {
1587
+ expected.push("B");
1588
+ actual.push( childNodeNames( this ) );
1589
+ });
1590
+ equal( expected.length, 7, "Expecting many parents" );
1591
+ deepEqual( actual, expected, "Correct childNodes after setting HTML" );
1592
+
1593
+ actual = []; expected = [];
1594
+ fixture.html( valueObj("<style>.foobar{color:green;}</style>") ).each(function() {
1595
+ expected.push("STYLE");
1596
+ actual.push( childNodeNames( this ) );
1597
+ });
1598
+ equal( expected.length, 1, "Expecting one parent" );
1599
+ deepEqual( actual, expected, "Found the inserted style element" );
1600
+
1601
+ fixture.html( valueObj("<select/>") );
1602
+ jQuery("#qunit-fixture select").html( valueObj("<option>O1</option><option selected='selected'>O2</option><option>O3</option>") );
1603
+ equal( jQuery("#qunit-fixture select").val(), "O2", "Selected option correct" );
1604
+
1605
+ tmp = fixture.html(
1606
+ valueObj([
1607
+ "<script type='something/else'>ok( false, 'evaluated: non-script' );</script>",
1608
+ "<script type='text/javascript'>ok( true, 'evaluated: text/javascript' );</script>",
1609
+ "<script type='text/ecmascript'>ok( true, 'evaluated: text/ecmascript' );</script>",
1610
+ "<script>ok( true, 'evaluated: no type' );</script>",
1611
+ "<div>",
1612
+ "<script type='something/else'>ok( false, 'evaluated: inner non-script' );</script>",
1613
+ "<script type='text/javascript'>ok( true, 'evaluated: inner text/javascript' );</script>",
1614
+ "<script type='text/ecmascript'>ok( true, 'evaluated: inner text/ecmascript' );</script>",
1615
+ "<script>ok( true, 'evaluated: inner no type' );</script>",
1616
+ "</div>"
1617
+ ].join(""))
1618
+ ).find("script");
1619
+ equal( tmp.length, 8, "All script tags remain." );
1620
+ equal( tmp[ 0 ].type, "something/else", "Non-evaluated type." );
1621
+ equal( tmp[ 1 ].type, "text/javascript", "Evaluated type." );
1622
+
1623
+ fixture.html( valueObj("<script type='text/javascript'>ok( true, 'Injection of identical script' );</script>") );
1624
+ fixture.html( valueObj("<script type='text/javascript'>ok( true, 'Injection of identical script' );</script>") );
1625
+ fixture.html( valueObj("<script type='text/javascript'>ok( true, 'Injection of identical script' );</script>") );
1626
+ fixture.html( valueObj("foo <form><script type='text/javascript'>ok( true, 'Injection of identical script (#975)' );</script></form>") );
1627
+
1628
+ jQuery.scriptorder = 0;
1629
+ fixture.html( valueObj([
1630
+ "<script>",
1631
+ "equal( jQuery('#scriptorder').length, 1,'Execute after html' );",
1632
+ "equal( jQuery.scriptorder++, 0, 'Script is executed in order' );",
1633
+ "</script>",
1634
+ "<span id='scriptorder'><script>equal( jQuery.scriptorder++, 1, 'Script (nested) is executed in order');</script></span>",
1635
+ "<script>equal( jQuery.scriptorder++, 2, 'Script (unnested) is executed in order' );</script>"
1636
+ ].join("")) );
1637
+
1638
+ QUnit.reset();
1639
+ fixture.html( valueObj( fixture.text() ) );
1640
+ ok( /^[^<]*[^<\s][^<]*$/.test( fixture.html() ), "Replace html with text" );
1641
+ };
1642
+
1643
+ test( "html(String)", function() {
1644
+ testHtml( manipulationBareObj );
1645
+ });
1646
+
1647
+ test( "html(Function)", function() {
1648
+ testHtml( manipulationFunctionReturningObj );
1649
+ });
1650
+
1651
+ test( "html(Function) with incoming value", function() {
1652
+
1653
+ expect( 18 );
1654
+
1655
+ var els, actualhtml, pass, j, $div, $div2, insert;
1656
+
1657
+ els = jQuery("#foo > p");
1658
+ actualhtml = els.map(function() {
1659
+ return jQuery( this ).html();
1660
+ });
1661
+
1662
+ els.html(function( i, val ) {
1663
+ equal( val, actualhtml[ i ], "Make sure the incoming value is correct." );
1664
+ return "<b>test</b>";
1665
+ });
1666
+
1667
+ pass = true;
1668
+ els.each(function() {
1669
+ if ( this.childNodes.length !== 1 ) {
1670
+ pass = false;
1671
+ }
1672
+ });
1673
+ ok( pass, "Set HTML" );
1674
+
1675
+ QUnit.reset();
1676
+ // using contents will get comments regular, text, and comment nodes
1677
+ j = jQuery("#nonnodes").contents();
1678
+ actualhtml = j.map(function() {
1679
+ return jQuery( this ).html();
1680
+ });
1681
+
1682
+ j.html(function( i, val ) {
1683
+ equal( val, actualhtml[ i ], "Make sure the incoming value is correct." );
1684
+ return "<b>bold</b>";
1685
+ });
1686
+
1687
+ // Handle the case where no comment is in the document
1688
+ if ( j.length === 2 ) {
1689
+ equal( null, null, "Make sure the incoming value is correct." );
1690
+ }
1691
+
1692
+ j.find("b").removeData();
1693
+ equal( j.html().replace( / xmlns="[^"]+"/g, "" ).toLowerCase(), "<b>bold</b>", "Check node,textnode,comment with html()" );
1694
+
1695
+ $div = jQuery("<div />");
1696
+
1697
+ equal( $div.html(function( i, val ) {
1698
+ equal( val, "", "Make sure the incoming value is correct." );
1699
+ return 5;
1700
+ }).html(), "5", "Setting a number as html" );
1701
+
1702
+ equal( $div.html(function( i, val ) {
1703
+ equal( val, "5", "Make sure the incoming value is correct." );
1704
+ return 0;
1705
+ }).html(), "0", "Setting a zero as html" );
1706
+
1707
+ $div2 = jQuery("<div/>");
1708
+ insert = "&lt;div&gt;hello1&lt;/div&gt;";
1709
+ equal( $div2.html(function( i, val ) {
1710
+ equal( val, "", "Make sure the incoming value is correct." );
1711
+ return insert;
1712
+ }).html().replace(/>/g, "&gt;"), insert, "Verify escaped insertion." );
1713
+
1714
+ equal( $div2.html(function( i, val ) {
1715
+ equal( val.replace(/>/g, "&gt;"), insert, "Make sure the incoming value is correct." );
1716
+ return "x" + insert;
1717
+ }).html().replace( />/g, "&gt;" ), "x" + insert, "Verify escaped insertion." );
1718
+
1719
+ equal( $div2.html(function( i, val ) {
1720
+ equal( val.replace( />/g, "&gt;" ), "x" + insert, "Make sure the incoming value is correct." );
1721
+ return " " + insert;
1722
+ }).html().replace( />/g, "&gt;" ), " " + insert, "Verify escaped insertion." );
1723
+ });
1724
+
1725
+ test( "clone()/html() don't expose jQuery/Sizzle expandos (#12858)", function() {
1726
+
1727
+ expect( 2 );
1728
+
1729
+ var $content = jQuery("<div><b><i>text</i></b></div>").appendTo("#qunit-fixture"),
1730
+ expected = /^<b><i>text<\/i><\/b>$/i;
1731
+
1732
+ // Attach jQuery and Sizzle data (the latter by conducting a non-qSA search)
1733
+ $content.find(":nth-child(1):lt(4)").data( "test", true );
1734
+
1735
+ ok( expected.test( $content.clone( false )[ 0 ].innerHTML ), "clone()" );
1736
+ ok( expected.test( $content.html() ), "html()" );
1737
+ });
1738
+
1739
+ var testRemove = function( method ) {
1740
+ var first = jQuery("#ap").children(":first");
1741
+
1742
+ first.data("foo", "bar");
1743
+
1744
+ jQuery("#ap").children()[ method ]();
1745
+ ok( jQuery("#ap").text().length > 10, "Check text is not removed" );
1746
+ equal( jQuery("#ap").children().length, 0, "Check remove" );
1747
+
1748
+ equal( first.data("foo"), method == "remove" ? null : "bar", "first data" );
1749
+
1750
+ QUnit.reset();
1751
+ jQuery("#ap").children()[ method ]("a");
1752
+ ok( jQuery("#ap").text().length > 10, "Check text is not removed" );
1753
+ equal( jQuery("#ap").children().length, 1, "Check filtered remove" );
1754
+
1755
+ jQuery("#ap").children()[ method ]("a, code");
1756
+ equal( jQuery("#ap").children().length, 0, "Check multi-filtered remove" );
1757
+
1758
+ // using contents will get comments regular, text, and comment nodes
1759
+ // Handle the case where no comment is in the document
1760
+ ok( jQuery("#nonnodes").contents().length >= 2, "Check node,textnode,comment remove works" );
1761
+ jQuery("#nonnodes").contents()[ method ]();
1762
+ equal( jQuery("#nonnodes").contents().length, 0, "Check node,textnode,comment remove works" );
1763
+
1764
+ // manually clean up detached elements
1765
+ if (method === "detach") {
1766
+ first.remove();
1767
+ }
1768
+ };
1769
+
1770
+ test( "remove()", 8, function() {
1771
+ testRemove("remove");
1772
+ });
1773
+
1774
+ test( "remove() event cleaning ", 1, function() {
1775
+ var count, first, cleanUp;
1776
+
1777
+ count = 0;
1778
+ first = jQuery("#ap").children(":first");
1779
+ cleanUp = first.on( "click", function() {
1780
+ count++;
1781
+ }).remove().appendTo("#qunit-fixture").trigger("click");
1782
+
1783
+ strictEqual( 0, count, "Event handler has been removed" );
1784
+
1785
+ // Clean up detached data
1786
+ cleanUp.remove();
1787
+ });
1788
+
1789
+ test( "detach()", 8, function() {
1790
+ testRemove("detach");
1791
+ });
1792
+
1793
+ test( "detach() event cleaning ", 1, function() {
1794
+ var count, first, cleanUp;
1795
+
1796
+ count = 0;
1797
+ first = jQuery("#ap").children(":first");
1798
+ cleanUp = first.on( "click", function() {
1799
+ count++;
1800
+ }).detach().appendTo("#qunit-fixture").trigger("click");
1801
+
1802
+ strictEqual( 1, count, "Event handler has not been removed" );
1803
+
1804
+ // Clean up detached data
1805
+ cleanUp.remove();
1806
+ });
1807
+
1808
+ test("empty()", function() {
1809
+
1810
+ expect( 6 );
1811
+
1812
+ equal( jQuery("#ap").children().empty().text().length, 0, "Check text is removed" );
1813
+ equal( jQuery("#ap").children().length, 4, "Check elements are not removed" );
1814
+
1815
+ // using contents will get comments regular, text, and comment nodes
1816
+ var j = jQuery("#nonnodes").contents();
1817
+ j.empty();
1818
+ equal( j.html(), "", "Check node,textnode,comment empty works" );
1819
+
1820
+ // Ensure oldIE empties selects (#12336)
1821
+ notEqual( $("#select1").find("option").length, 0, "Have some initial options" );
1822
+ $("#select1").empty();
1823
+ equal( $("#select1").find("option").length, 0, "No more option elements found" );
1824
+ equal( $("#select1")[0].options.length, 0, "options.length cleared as well" );
1825
+ });
1826
+
1827
+ test( "jQuery.cleanData", function() {
1828
+
1829
+ expect( 14 );
1830
+
1831
+ var type, pos, div, child;
1832
+
1833
+ type = "remove";
1834
+
1835
+ // Should trigger 4 remove event
1836
+ div = getDiv().remove();
1837
+
1838
+ // Should both do nothing
1839
+ pos = "Outer";
1840
+ div.trigger("click");
1841
+
1842
+ pos = "Inner";
1843
+ div.children().trigger("click");
1844
+
1845
+ type = "empty";
1846
+ div = getDiv();
1847
+ child = div.children();
1848
+
1849
+ // Should trigger 2 remove event
1850
+ div.empty();
1851
+
1852
+ // Should trigger 1
1853
+ pos = "Outer";
1854
+ div.trigger("click");
1855
+
1856
+ // Should do nothing
1857
+ pos = "Inner";
1858
+ child.trigger("click");
1859
+
1860
+ // Should trigger 2
1861
+ div.remove();
1862
+
1863
+ type = "html";
1864
+
1865
+ div = getDiv();
1866
+ child = div.children();
1867
+
1868
+ // Should trigger 2 remove event
1869
+ div.html("<div></div>");
1870
+
1871
+ // Should trigger 1
1872
+ pos = "Outer";
1873
+ div.trigger("click");
1874
+
1875
+ // Should do nothing
1876
+ pos = "Inner";
1877
+ child.trigger("click");
1878
+
1879
+ // Should trigger 2
1880
+ div.remove();
1881
+
1882
+ function getDiv() {
1883
+ var div = jQuery("<div class='outer'><div class='inner'></div></div>").on( "click", function() {
1884
+ ok( true, type + " " + pos + " Click event fired." );
1885
+ }).on( "focus", function() {
1886
+ ok( true, type + " " + pos + " Focus event fired." );
1887
+ }).find("div").on( "click", function() {
1888
+ ok( false, type + " " + pos + " Click event fired." );
1889
+ }).on( "focus", function() {
1890
+ ok( false, type + " " + pos + " Focus event fired." );
1891
+ }).end().appendTo("body");
1892
+
1893
+ div[ 0 ].detachEvent = div[ 0 ].removeEventListener = function( t ) {
1894
+ ok( true, type + " Outer " + t + " event unbound" );
1895
+ };
1896
+
1897
+ div[ 0 ].firstChild.detachEvent = div[ 0 ].firstChild.removeEventListener = function( t ) {
1898
+ ok( true, type + " Inner " + t + " event unbound" );
1899
+ };
1900
+
1901
+ return div;
1902
+ }
1903
+ });
1904
+
1905
+ test( "jQuery.buildFragment - no plain-text caching (Bug #6779)", function() {
1906
+
1907
+ expect( 1 );
1908
+
1909
+ // DOM manipulation fails if added text matches an Object method
1910
+ var i,
1911
+ $f = jQuery( "<div />" ).appendTo( "#qunit-fixture" ),
1912
+ bad = [ "start-", "toString", "hasOwnProperty", "append", "here&there!", "-end" ];
1913
+
1914
+ for ( i = 0; i < bad.length; i++ ) {
1915
+ try {
1916
+ $f.append( bad[ i ] );
1917
+ }
1918
+ catch( e ) {}
1919
+ }
1920
+ equal( $f.text(), bad.join(""), "Cached strings that match Object properties" );
1921
+ $f.remove();
1922
+ });
1923
+
1924
+ test( "jQuery.html - execute scripts escaped with html comment or CDATA (#9221)", function() {
1925
+
1926
+ expect( 3 );
1927
+
1928
+ jQuery([
1929
+ "<script type='text/javascript'>",
1930
+ "<!--",
1931
+ "ok( true, '<!-- handled' );",
1932
+ "//-->",
1933
+ "</script>"
1934
+ ].join("\n")).appendTo("#qunit-fixture");
1935
+ jQuery([
1936
+ "<script type='text/javascript'>",
1937
+ "<![CDATA[",
1938
+ "ok( true, '<![CDATA[ handled' );",
1939
+ "//]]>",
1940
+ "</script>"
1941
+ ].join("\n")).appendTo("#qunit-fixture");
1942
+ jQuery([
1943
+ "<script type='text/javascript'>",
1944
+ "<!--//--><![CDATA[//><!--",
1945
+ "ok( true, '<!--//--><![CDATA[//><!-- (Drupal case) handled' );",
1946
+ "//--><!]]>",
1947
+ "</script>"
1948
+ ].join("\n")).appendTo("#qunit-fixture");
1949
+ });
1950
+
1951
+ test( "jQuery.buildFragment - plain objects are not a document #8950", function() {
1952
+
1953
+ expect( 1 );
1954
+
1955
+ try {
1956
+ jQuery( "<input type='hidden'>", {} );
1957
+ ok( true, "Does not allow attribute object to be treated like a doc object" );
1958
+ } catch ( e ) {}
1959
+ });
1960
+
1961
+ test( "jQuery.clone - no exceptions for object elements #9587", function() {
1962
+
1963
+ expect( 1 );
1964
+
1965
+ try {
1966
+ jQuery("#no-clone-exception").clone();
1967
+ ok( true, "cloned with no exceptions" );
1968
+ } catch( e ) {
1969
+ ok( false, e.message );
1970
+ }
1971
+ });
1972
+
1973
+ test( "jQuery(<tag>) & wrap[Inner/All]() handle unknown elems (#10667)", function() {
1974
+
1975
+ expect( 2 );
1976
+
1977
+ var $wraptarget = jQuery( "<div id='wrap-target'>Target</div>" ).appendTo( "#qunit-fixture" ),
1978
+ $section = jQuery( "<section>" ).appendTo( "#qunit-fixture" );
1979
+
1980
+ $wraptarget.wrapAll("<aside style='background-color:green'></aside>");
1981
+
1982
+ notEqual( $wraptarget.parent("aside").get( 0 ).style.backgroundColor, "transparent", "HTML5 elements created with wrapAll inherit styles" );
1983
+ notEqual( $section.get( 0 ).style.backgroundColor, "transparent", "HTML5 elements create with jQuery( string ) inherit styles" );
1984
+ });
1985
+
1986
+ test( "Cloned, detached HTML5 elems (#10667,10670)", function() {
1987
+
1988
+ expect( 7 );
1989
+
1990
+ var $clone,
1991
+ $section = jQuery( "<section>" ).appendTo( "#qunit-fixture" );
1992
+
1993
+ // First clone
1994
+ $clone = $section.clone();
1995
+
1996
+ // Infer that the test is being run in IE<=8
1997
+ if ( $clone[ 0 ].outerHTML && !jQuery.support.opacity ) {
1998
+ // This branch tests cloning nodes by reading the outerHTML, used only in IE<=8
1999
+ equal( $clone[ 0 ].outerHTML, "<section></section>", "detached clone outerHTML matches '<section></section>'" );
2000
+ } else {
2001
+ // This branch tests a known behaviour in modern browsers that should never fail.
2002
+ // Included for expected test count symmetry (expecting 1)
2003
+ equal( $clone[ 0 ].nodeName, "SECTION", "detached clone nodeName matches 'SECTION' in modern browsers" );
2004
+ }
2005
+
2006
+ // Bind an event
2007
+ $section.bind( "click", function( event ) {
2008
+ ok( true, "clone fired event" );
2009
+ });
2010
+
2011
+ // Second clone (will have an event bound)
2012
+ $clone = $section.clone( true );
2013
+
2014
+ // Trigger an event from the first clone
2015
+ $clone.trigger("click");
2016
+ $clone.unbind("click");
2017
+
2018
+ // Add a child node with text to the original
2019
+ $section.append("<p>Hello</p>");
2020
+
2021
+ // Third clone (will have child node and text)
2022
+ $clone = $section.clone( true );
2023
+
2024
+ equal( $clone.find("p").text(), "Hello", "Assert text in child of clone" );
2025
+
2026
+ // Trigger an event from the third clone
2027
+ $clone.trigger("click");
2028
+ $clone.unbind("click");
2029
+
2030
+ // Add attributes to copy
2031
+ $section.attr({
2032
+ "class": "foo bar baz",
2033
+ "title": "This is a title"
2034
+ });
2035
+
2036
+ // Fourth clone (will have newly added attributes)
2037
+ $clone = $section.clone( true );
2038
+
2039
+ equal( $clone.attr("class"), $section.attr("class"), "clone and element have same class attribute" );
2040
+ equal( $clone.attr("title"), $section.attr("title"), "clone and element have same title attribute" );
2041
+
2042
+ // Remove the original
2043
+ $section.remove();
2044
+
2045
+ // Clone the clone
2046
+ $section = $clone.clone( true );
2047
+
2048
+ // Remove the clone
2049
+ $clone.remove();
2050
+
2051
+ // Trigger an event from the clone of the clone
2052
+ $section.trigger("click");
2053
+
2054
+ // Unbind any remaining events
2055
+ $section.unbind("click");
2056
+ $clone.unbind("click");
2057
+ });
2058
+
2059
+ test( "Guard against exceptions when clearing safeChildNodes", function() {
2060
+
2061
+ expect( 1 );
2062
+
2063
+ var div;
2064
+
2065
+ try {
2066
+ div = jQuery("<div/><hr/><code/><b/>");
2067
+ } catch(e) {}
2068
+
2069
+ ok( div && div.jquery, "Created nodes safely, guarded against exceptions on safeChildNodes[ -1 ]" );
2070
+ });
2071
+
2072
+ test( "Ensure oldIE creates a new set on appendTo (#8894)", function() {
2073
+
2074
+ expect( 5 );
2075
+
2076
+ strictEqual( jQuery("<div/>").clone().addClass("test").appendTo("<div/>").end().end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.clone" );
2077
+ strictEqual( jQuery("<div/>").find("p").end().addClass("test").appendTo("<div/>").end().end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.fn.find" );
2078
+ strictEqual( jQuery("<div/>").text("test").addClass("test").appendTo("<div/>").end().end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.fn.text" );
2079
+ strictEqual( jQuery("<bdi/>").clone().addClass("test").appendTo("<div/>").end().end().hasClass("test"), false, "Check jQuery.fn.appendTo after clone html5 element" );
2080
+ strictEqual( jQuery("<p/>").appendTo("<div/>").end().length, jQuery("<p>test</p>").appendTo("<div/>").end().length, "Elements created with createElement and with createDocumentFragment should be treated alike" );
2081
+ });
2082
+
2083
+ test( "html() - script exceptions bubble (#11743)", function() {
2084
+
2085
+ expect( 2 );
2086
+
2087
+ raises(function() {
2088
+ jQuery("#qunit-fixture").html("<script>undefined(); ok( false, 'error not thrown' );</script>");
2089
+ ok( false, "error ignored" );
2090
+ }, "exception bubbled from inline script" );
2091
+
2092
+ raises(function() {
2093
+ jQuery("#qunit-fixture").html("<script src='data/badcall.js'></script>");
2094
+ ok( false, "error ignored" );
2095
+ }, "exception bubbled from remote script" );
2096
+ });
2097
+
2098
+ test( "checked state is cloned with clone()", function() {
2099
+
2100
+ expect( 2 );
2101
+
2102
+ var elem = jQuery.parseHTML("<input type='checkbox' checked='checked'/>")[ 0 ];
2103
+ elem.checked = false;
2104
+ equal( jQuery(elem).clone().attr("id","clone")[ 0 ].checked, false, "Checked false state correctly cloned" );
2105
+
2106
+ elem = jQuery.parseHTML("<input type='checkbox'/>")[ 0 ];
2107
+ elem.checked = true;
2108
+ equal( jQuery(elem).clone().attr("id","clone")[ 0 ].checked, true, "Checked true state correctly cloned" );
2109
+ });
2110
+
2111
+ test( "manipulate mixed jQuery and text (#12384, #12346)", function() {
2112
+
2113
+ expect( 2 );
2114
+
2115
+ var div = jQuery("<div>a</div>").append( "&nbsp;", jQuery("<span>b</span>"), "&nbsp;", jQuery("<span>c</span>") ),
2116
+ nbsp = String.fromCharCode( 160 );
2117
+
2118
+ equal( div.text(), "a" + nbsp + "b" + nbsp+ "c", "Appending mixed jQuery with text nodes" );
2119
+
2120
+ div = jQuery("<div><div></div></div>")
2121
+ .find("div")
2122
+ .after( "<p>a</p>", "<p>b</p>" )
2123
+ .parent();
2124
+ equal( div.find("*").length, 3, "added 2 paragraphs after inner div" );
2125
+ });
2126
+
2127
+ testIframeWithCallback( "buildFragment works even if document[0] is iframe's window object in IE9/10 (#12266)", "manipulation/iframe-denied.html", function( test ) {
2128
+ expect( 1 );
2129
+
2130
+ ok( test.status, test.description );
2131
+ });
2132
+
2133
+ test( "script evaluation (#11795)", function() {
2134
+
2135
+ expect( 11 );
2136
+
2137
+ var scriptsIn, scriptsOut,
2138
+ fixture = jQuery("#qunit-fixture").empty(),
2139
+ objGlobal = (function() {
2140
+ return this;
2141
+ })(),
2142
+ isOk = objGlobal.ok,
2143
+ notOk = function() {
2144
+ var args = arguments;
2145
+ args[ 0 ] = !args[ 0 ];
2146
+ return isOk.apply( this, args );
2147
+ };
2148
+
2149
+ objGlobal.ok = notOk;
2150
+ scriptsIn = jQuery([
2151
+ "<script type='something/else'>ok( false, 'evaluated: non-script' );</script>",
2152
+ "<script type='text/javascript'>ok( true, 'evaluated: text/javascript' );</script>",
2153
+ "<script type='text/ecmascript'>ok( true, 'evaluated: text/ecmascript' );</script>",
2154
+ "<script>ok( true, 'evaluated: no type' );</script>",
2155
+ "<div>",
2156
+ "<script type='something/else'>ok( false, 'evaluated: inner non-script' );</script>",
2157
+ "<script type='text/javascript'>ok( true, 'evaluated: inner text/javascript' );</script>",
2158
+ "<script type='text/ecmascript'>ok( true, 'evaluated: inner text/ecmascript' );</script>",
2159
+ "<script>ok( true, 'evaluated: inner no type' );</script>",
2160
+ "</div>"
2161
+ ].join(""));
2162
+ scriptsIn.appendTo( jQuery("<div class='detached'/>") );
2163
+ objGlobal.ok = isOk;
2164
+
2165
+ scriptsOut = fixture.append( scriptsIn ).find("script");
2166
+ equal( scriptsOut[ 0 ].type, "something/else", "Non-evaluated type." );
2167
+ equal( scriptsOut[ 1 ].type, "text/javascript", "Evaluated type." );
2168
+ deepEqual( scriptsOut.get(), fixture.find("script").get(), "All script tags remain." );
2169
+
2170
+ objGlobal.ok = notOk;
2171
+ scriptsOut = scriptsOut.add( scriptsOut.clone() ).appendTo( fixture.find("div") );
2172
+ deepEqual( fixture.find("div script").get(), scriptsOut.get(), "Scripts cloned without reevaluation" );
2173
+ fixture.append( scriptsOut.detach() );
2174
+ deepEqual( fixture.find("> script").get(), scriptsOut.get(), "Scripts detached without reevaluation" );
2175
+ objGlobal.ok = isOk;
2176
+ });
2177
+
2178
+ test( "wrapping scripts (#10470)", function() {
2179
+
2180
+ expect( 2 );
2181
+
2182
+ var script = document.createElement("script");
2183
+ script.text = script.textContent = "ok( !document.eval10470, 'script evaluated once' ); document.eval10470 = true;";
2184
+
2185
+ document.eval10470 = false;
2186
+ jQuery("#qunit-fixture").empty()[0].appendChild( script );
2187
+ jQuery("#qunit-fixture script").wrap("<b></b>");
2188
+ strictEqual( script.parentNode, jQuery("#qunit-fixture > b")[ 0 ], "correctly wrapped" );
2189
+ jQuery( script ).remove();
2190
+ });
2191
+
2192
+ test( "insertAfter, insertBefore, etc do not work when destination is original element. Element is removed (#4087)", function() {
2193
+
2194
+ expect( 10 );
2195
+
2196
+ var elems;
2197
+
2198
+ jQuery.each([
2199
+ "appendTo",
2200
+ "prependTo",
2201
+ "insertBefore",
2202
+ "insertAfter",
2203
+ "replaceAll"
2204
+ ], function( index, name ) {
2205
+ elems = jQuery( [
2206
+ "<ul id='test4087-complex'><li class='test4087'><div>c1</div>h1</li><li><div>c2</div>h2</li></ul>",
2207
+ "<div id='test4087-simple'><div class='test4087-1'>1<div class='test4087-2'>2</div><div class='test4087-3'>3</div></div></div>",
2208
+ "<div id='test4087-multiple'><div class='test4087-multiple'>1</div><div class='test4087-multiple'>2</div></div>"
2209
+ ].join("") ).appendTo( "#qunit-fixture" );
2210
+
2211
+ // complex case based on http://jsfiddle.net/pbramos/gZ7vB/
2212
+ jQuery("#test4087-complex div")[ name ]("#test4087-complex li:last-child div:last-child");
2213
+ equal( jQuery("#test4087-complex li:last-child div").length, name === "replaceAll" ? 1 : 2, name +" a node to itself, complex case." );
2214
+
2215
+ // simple case
2216
+ jQuery( ".test4087-1" )[ name ](".test4087-1");
2217
+ equal( jQuery(".test4087-1").length, 1, name +" a node to itself, simple case." );
2218
+
2219
+ // clean for next test
2220
+ jQuery("#test4087-complex").remove();
2221
+ jQuery("#test4087-simple").remove();
2222
+ jQuery("#test4087-multiple").remove();
2223
+ });
2224
+ });
2225
+
2226
+ test( "Index for function argument should be received (#13094)", 2, function() {
2227
+ var i = 0;
2228
+
2229
+ jQuery("<div/><div/>").before(function( index ) {
2230
+ equal( index, i++, "Index should be correct" );
2231
+ });
2232
+
2233
+ });
2234
+
2235
+ test( "Make sure jQuery.fn.remove can work on elements in documentFragment", 1, function() {
2236
+ var fragment = document.createDocumentFragment(),
2237
+ div = fragment.appendChild( document.createElement("div") );
2238
+
2239
+ jQuery( div ).remove();
2240
+
2241
+ equal( fragment.childNodes.length, 0, "div element was removed from documentFragment" );
2242
+ });