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,1332 @@
1
+ module( "attributes", {
2
+ teardown: moduleTeardown
3
+ });
4
+
5
+ var bareObj = function( value ) {
6
+ return value;
7
+ };
8
+
9
+ var functionReturningObj = function( value ) {
10
+ return (function() {
11
+ return value;
12
+ });
13
+ };
14
+
15
+ /*
16
+ ======== local reference =======
17
+ bareObj and functionReturningObj can be used to test passing functions to setters
18
+ See testVal below for an example
19
+
20
+ bareObj( value );
21
+ This function returns whatever value is passed in
22
+
23
+ functionReturningObj( value );
24
+ Returns a function that returns the value
25
+ */
26
+
27
+ test( "jQuery.propFix integrity test", function() {
28
+ expect( 1 );
29
+
30
+ // This must be maintained and equal jQuery.attrFix when appropriate
31
+ // Ensure that accidental or erroneous property
32
+ // overwrites don't occur
33
+ // This is simply for better code coverage and future proofing.
34
+ var props = {
35
+ "tabindex": "tabIndex",
36
+ "readonly": "readOnly",
37
+ "for": "htmlFor",
38
+ "class": "className",
39
+ "maxlength": "maxLength",
40
+ "cellspacing": "cellSpacing",
41
+ "cellpadding": "cellPadding",
42
+ "rowspan": "rowSpan",
43
+ "colspan": "colSpan",
44
+ "usemap": "useMap",
45
+ "frameborder": "frameBorder",
46
+ "contenteditable": "contentEditable"
47
+ };
48
+
49
+ if ( !jQuery.support.enctype ) {
50
+ props.enctype = "encoding";
51
+ }
52
+
53
+ deepEqual( props, jQuery.propFix, "jQuery.propFix passes integrity check" );
54
+ });
55
+
56
+ test( "attr(String)", function() {
57
+ expect( 50 );
58
+
59
+ equal( jQuery("#text1").attr("type"), "text", "Check for type attribute" );
60
+ equal( jQuery("#radio1").attr("type"), "radio", "Check for type attribute" );
61
+ equal( jQuery("#check1").attr("type"), "checkbox", "Check for type attribute" );
62
+ equal( jQuery("#simon1").attr("rel"), "bookmark", "Check for rel attribute" );
63
+ equal( jQuery("#google").attr("title"), "Google!", "Check for title attribute" );
64
+ equal( jQuery("#mark").attr("hreflang"), "en", "Check for hreflang attribute" );
65
+ equal( jQuery("#en").attr("lang"), "en", "Check for lang attribute" );
66
+ equal( jQuery("#simon").attr("class"), "blog link", "Check for class attribute" );
67
+ equal( jQuery("#name").attr("name"), "name", "Check for name attribute" );
68
+ equal( jQuery("#text1").attr("name"), "action", "Check for name attribute" );
69
+ ok( jQuery("#form").attr("action").indexOf("formaction") >= 0, "Check for action attribute" );
70
+ equal( jQuery("#text1").attr("value", "t").attr("value"), "t", "Check setting the value attribute" );
71
+ equal( jQuery("#text1").attr("value", "").attr("value"), "", "Check setting the value attribute to empty string" );
72
+ equal( jQuery("<div value='t'></div>").attr("value"), "t", "Check setting custom attr named 'value' on a div" );
73
+ equal( jQuery("#form").attr("blah", "blah").attr("blah"), "blah", "Set non-existant attribute on a form" );
74
+ equal( jQuery("#foo").attr("height"), undefined, "Non existent height attribute should return undefined" );
75
+
76
+ // [7472] & [3113] (form contains an input with name="action" or name="id")
77
+ var extras = jQuery("<input id='id' name='id' /><input id='name' name='name' /><input id='target' name='target' />").appendTo("#testForm");
78
+ equal( jQuery("#form").attr("action","newformaction").attr("action"), "newformaction", "Check that action attribute was changed" );
79
+ equal( jQuery("#testForm").attr("target"), undefined, "Retrieving target does not equal the input with name=target" );
80
+ equal( jQuery("#testForm").attr("target", "newTarget").attr("target"), "newTarget", "Set target successfully on a form" );
81
+ equal( jQuery("#testForm").removeAttr("id").attr("id"), undefined, "Retrieving id does not equal the input with name=id after id is removed [#7472]" );
82
+ // Bug #3685 (form contains input with name="name")
83
+ equal( jQuery("#testForm").attr("name"), undefined, "Retrieving name does not retrieve input with name=name" );
84
+ extras.remove();
85
+
86
+ equal( jQuery("#text1").attr("maxlength"), "30", "Check for maxlength attribute" );
87
+ equal( jQuery("#text1").attr("maxLength"), "30", "Check for maxLength attribute" );
88
+ equal( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" );
89
+
90
+ // using innerHTML in IE causes href attribute to be serialized to the full path
91
+ jQuery("<a/>").attr({
92
+ "id": "tAnchor5",
93
+ "href": "#5"
94
+ }).appendTo("#qunit-fixture");
95
+ equal( jQuery("#tAnchor5").attr("href"), "#5", "Check for non-absolute href (an anchor)" );
96
+ jQuery("<a id='tAnchor6' href='#5' />").appendTo("#qunit-fixture");
97
+ equal( jQuery("#tAnchor5").prop("href"), jQuery("#tAnchor6").prop("href"), "Check for absolute href prop on an anchor" );
98
+
99
+ $("<script type='jquery/test' src='#5' id='scriptSrc'></script>").appendTo("#qunit-fixture");
100
+ equal( jQuery("#tAnchor5").prop("href"), jQuery("#scriptSrc").prop("src"), "Check for absolute src prop on a script" );
101
+
102
+ // list attribute is readonly by default in browsers that support it
103
+ jQuery("#list-test").attr( "list", "datalist" );
104
+ equal( jQuery("#list-test").attr("list"), "datalist", "Check setting list attribute" );
105
+
106
+ // Related to [5574] and [5683]
107
+ var body = document.body, $body = jQuery( body );
108
+
109
+ strictEqual( $body.attr("foo"), undefined, "Make sure that a non existent attribute returns undefined" );
110
+
111
+ body.setAttribute( "foo", "baz" );
112
+ equal( $body.attr("foo"), "baz", "Make sure the dom attribute is retrieved when no expando is found" );
113
+
114
+ $body.attr( "foo","cool" );
115
+ equal( $body.attr("foo"), "cool", "Make sure that setting works well when both expando and dom attribute are available" );
116
+
117
+ body.removeAttribute("foo"); // Cleanup
118
+
119
+ var select = document.createElement("select"),
120
+ optgroup = document.createElement("optgroup"),
121
+ option = document.createElement("option");
122
+
123
+ optgroup.appendChild( option );
124
+ select.appendChild( optgroup );
125
+
126
+ equal( jQuery( option ).prop("selected"), true, "Make sure that a single option is selected, even when in an optgroup." );
127
+
128
+ var $img = jQuery("<img style='display:none' width='215' height='53' src='data/1x1.jpg'/>").appendTo("body");
129
+ equal( $img.attr("width"), "215", "Retrieve width attribute an an element with display:none." );
130
+ equal( $img.attr("height"), "53", "Retrieve height attribute an an element with display:none." );
131
+
132
+ // Check for style support
133
+ var styleElem = jQuery("<div/>").appendTo("#qunit-fixture").css({
134
+ background: "url(UPPERlower.gif)"
135
+ });
136
+ ok( !!~styleElem.attr("style").indexOf("UPPERlower.gif"), "Check style attribute getter" );
137
+ ok( !!~styleElem.attr("style", "position:absolute;").attr("style").indexOf("absolute"), "Check style setter" );
138
+
139
+ // Check value on button element (#1954)
140
+ var $button = jQuery("<button>text</button>").insertAfter("#button");
141
+ strictEqual( $button.attr("value"), undefined, "Absence of value attribute on a button" );
142
+ equal( $button.attr( "value", "foobar" ).attr("value"), "foobar", "Value attribute on a button does not return innerHTML" );
143
+ equal( $button.attr("value", "baz").html(), "text", "Setting the value attribute does not change innerHTML" );
144
+
145
+ // Attributes with a colon on a table element (#1591)
146
+ equal( jQuery("#table").attr("test:attrib"), undefined, "Retrieving a non-existent attribute on a table with a colon does not throw an error." );
147
+ equal( jQuery("#table").attr( "test:attrib", "foobar" ).attr("test:attrib"), "foobar", "Setting an attribute on a table with a colon does not throw an error." );
148
+
149
+ var $form = jQuery("<form class='something'></form>").appendTo("#qunit-fixture");
150
+ equal( $form.attr("class"), "something", "Retrieve the class attribute on a form." );
151
+
152
+ var $a = jQuery("<a href='#' onclick='something()'>Click</a>").appendTo("#qunit-fixture");
153
+ equal( $a.attr("onclick"), "something()", "Retrieve ^on attribute without anonymous function wrapper." );
154
+
155
+ ok( jQuery("<div/>").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." );
156
+ ok( jQuery("<div/>").attr("title") === undefined, "Make sure undefined is returned when no attribute is found." );
157
+ equal( jQuery("<div/>").attr( "title", "something" ).attr("title"), "something", "Set the title attribute." );
158
+ ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." );
159
+ equal( jQuery("<div/>").attr("value"), undefined, "An unset value on a div returns undefined." );
160
+ strictEqual( jQuery("<select><option value='property'></option></select>").attr("value"), undefined, "An unset value on a select returns undefined." );
161
+
162
+ $form = jQuery("#form").attr( "enctype", "multipart/form-data" );
163
+ equal( $form.prop("enctype"), "multipart/form-data", "Set the enctype of a form (encoding in IE6/7 #6743)" );
164
+
165
+ });
166
+
167
+ test( "attr(String) on cloned elements, #9646", function() {
168
+ expect( 4 );
169
+
170
+ var div,
171
+ input = jQuery("<input name='tester' />");
172
+
173
+ input.attr("name");
174
+
175
+ strictEqual( input.clone( true ).attr( "name", "test" )[ 0 ].name, "test", "Name attribute should be changed on cloned element" );
176
+
177
+ div = jQuery("<div id='tester' />");
178
+ div.attr("id");
179
+
180
+ strictEqual( div.clone( true ).attr( "id", "test" )[ 0 ].id, "test", "Id attribute should be changed on cloned element" );
181
+
182
+ input = jQuery("<input value='tester' />");
183
+ input.attr("value");
184
+
185
+ strictEqual( input.clone( true ).attr( "value", "test" )[ 0 ].value, "test", "Value attribute should be changed on cloned element" );
186
+
187
+ strictEqual( input.clone( true ).attr( "value", 42 )[ 0 ].value, "42", "Value attribute should be changed on cloned element" );
188
+ });
189
+
190
+ test( "attr(String) in XML Files", function() {
191
+ expect( 3 );
192
+ var xml = createDashboardXML();
193
+ equal( jQuery( "locations", xml ).attr("class"), "foo", "Check class attribute in XML document" );
194
+ equal( jQuery( "location", xml ).attr("for"), "bar", "Check for attribute in XML document" );
195
+ equal( jQuery( "location", xml ).attr("checked"), "different", "Check that hooks are not attached in XML document" );
196
+ });
197
+
198
+ test( "attr(String, Function)", function() {
199
+ expect( 2 );
200
+
201
+ equal(
202
+ jQuery("#text1").attr( "value", function() {
203
+ return this.id;
204
+ }).attr("value"),
205
+ "text1",
206
+ "Set value from id"
207
+ );
208
+
209
+ equal(
210
+ jQuery("#text1").attr( "title", function(i) {
211
+ return i;
212
+ }).attr("title"),
213
+ "0",
214
+ "Set value with an index"
215
+ );
216
+ });
217
+
218
+ test( "attr(Hash)", function() {
219
+ expect( 3 );
220
+ var pass = true;
221
+ jQuery("div").attr({
222
+ "foo": "baz",
223
+ "zoo": "ping"
224
+ }).each(function() {
225
+ if ( this.getAttribute("foo") != "baz" && this.getAttribute("zoo") != "ping" ) {
226
+ pass = false;
227
+ }
228
+ });
229
+
230
+ ok( pass, "Set Multiple Attributes" );
231
+
232
+ equal(
233
+ jQuery("#text1").attr({
234
+ "value": function() {
235
+ return this["id"];
236
+ }}).attr("value"),
237
+ "text1",
238
+ "Set attribute to computed value #1"
239
+ );
240
+
241
+ equal(
242
+ jQuery("#text1").attr({
243
+ "title": function(i) {
244
+ return i;
245
+ }
246
+ }).attr("title"),
247
+ "0",
248
+ "Set attribute to computed value #2"
249
+ );
250
+ });
251
+
252
+ test( "attr(String, Object)", function() {
253
+ expect( 71 );
254
+
255
+ var div = jQuery("div").attr("foo", "bar"),
256
+ i = 0,
257
+ fail = false;
258
+
259
+ for ( ; i < div.length; i++ ) {
260
+ if ( div[ i ].getAttribute("foo") !== "bar" ) {
261
+ fail = i;
262
+ break;
263
+ }
264
+ }
265
+
266
+ equal( fail, false, "Set Attribute, the #" + fail + " element didn't get the attribute 'foo'" );
267
+
268
+ ok(
269
+ jQuery("#foo").attr({
270
+ "width": null
271
+ }),
272
+ "Try to set an attribute to nothing"
273
+ );
274
+
275
+ jQuery("#name").attr( "name", "something" );
276
+ equal( jQuery("#name").attr("name"), "something", "Set name attribute" );
277
+ jQuery("#name").attr( "name", null );
278
+ equal( jQuery("#name").attr("name"), undefined, "Remove name attribute" );
279
+
280
+ var $input = jQuery( "<input>", {
281
+ name: "something",
282
+ id: "specified"
283
+ });
284
+ equal( $input.attr("name"), "something", "Check element creation gets/sets the name attribute." );
285
+ equal( $input.attr("id"), "specified", "Check element creation gets/sets the id attribute." );
286
+
287
+ // As of fixing #11115, we only guarantee boolean property update for checked and selected
288
+ $input = jQuery("<input type='checkbox'/>").attr( "checked", true );
289
+ equal( $input.prop("checked"), true, "Setting checked updates property (verified by .prop)" );
290
+ equal( $input[0].checked, true, "Setting checked updates property (verified by native property)" );
291
+ $input = jQuery("<option/>").attr( "selected", true );
292
+ equal( $input.prop("selected"), true, "Setting selected updates property (verified by .prop)" );
293
+ equal( $input[0].selected, true, "Setting selected updates property (verified by native property)" );
294
+
295
+ $input = jQuery("#check2");
296
+ $input.prop( "checked", true ).prop( "checked", false ).attr( "checked", true );
297
+ equal( $input.attr("checked"), "checked", "Set checked (verified by .attr)" );
298
+ $input.prop( "checked", false ).prop( "checked", true ).attr( "checked", false );
299
+ equal( $input.attr("checked"), undefined, "Remove checked (verified by .attr)" );
300
+
301
+ $input = jQuery("#text1").prop( "readOnly", true ).prop( "readOnly", false ).attr( "readonly", true );
302
+ equal( $input.attr("readonly"), "readonly", "Set readonly (verified by .attr)" );
303
+ $input.prop( "readOnly", false ).prop( "readOnly", true ).attr( "readonly", false );
304
+ equal( $input.attr("readonly"), undefined, "Remove readonly (verified by .attr)" );
305
+
306
+ $input = jQuery("#check2").attr( "checked", true ).attr( "checked", false ).prop( "checked", true );
307
+ equal( $input[0].checked, true, "Set checked property (verified by native property)" );
308
+ equal( $input.prop("checked"), true, "Set checked property (verified by .prop)" );
309
+ equal( $input.attr("checked"), undefined, "Setting checked property doesn't affect checked attribute" );
310
+ $input.attr( "checked", false ).attr( "checked", true ).prop( "checked", false );
311
+ equal( $input[0].checked, false, "Clear checked property (verified by native property)" );
312
+ equal( $input.prop("checked"), false, "Clear checked property (verified by .prop)" );
313
+ equal( $input.attr("checked"), "checked", "Clearing checked property doesn't affect checked attribute" );
314
+
315
+ $input = jQuery("#check2").attr( "checked", false ).attr( "checked", "checked" );
316
+ equal( $input.attr("checked"), "checked", "Set checked to 'checked' (verified by .attr)" );
317
+
318
+ var $radios = jQuery("#checkedtest").find("input[type='radio']");
319
+ $radios.eq( 1 ).trigger("click");
320
+ equal( $radios.eq( 1 ).prop("checked"), true, "Second radio was checked when clicked" );
321
+ equal( $radios.eq( 0 ).attr("checked"), "checked", "First radio is still [checked]" );
322
+
323
+ $input = jQuery("#text1").attr( "readonly", false ).prop( "readOnly", true );
324
+ equal( $input[0].readOnly, true, "Set readonly property (verified by native property)" );
325
+ equal( $input.prop("readOnly"), true, "Set readonly property (verified by .prop)" );
326
+ $input.attr( "readonly", true ).prop( "readOnly", false );
327
+ equal( $input[0].readOnly, false, "Clear readonly property (verified by native property)" );
328
+ equal( $input.prop("readOnly"), false, "Clear readonly property (verified by .prop)" );
329
+
330
+ $input = jQuery("#name").attr( "maxlength", "5" );
331
+ equal( $input[0].maxLength, 5, "Set maxlength (verified by native property)" );
332
+ $input.attr( "maxLength", "10" );
333
+ equal( $input[0].maxLength, 10, "Set maxlength (verified by native property)" );
334
+
335
+ // HTML5 boolean attributes
336
+ var $text = jQuery("#text1").attr({
337
+ "autofocus": true,
338
+ "required": true
339
+ });
340
+ equal( $text.attr("autofocus"), "autofocus", "Reading autofocus attribute yields 'autofocus'" );
341
+ equal( $text.attr( "autofocus", false ).attr("autofocus"), undefined, "Setting autofocus to false removes it" );
342
+ equal( $text.attr("required"), "required", "Reading required attribute yields 'required'" );
343
+ equal( $text.attr( "required", false ).attr("required"), undefined, "Setting required attribute to false removes it" );
344
+
345
+ var $details = jQuery("<details open></details>").appendTo("#qunit-fixture");
346
+ equal( $details.attr("open"), "open", "open attribute presense indicates true" );
347
+ equal( $details.attr( "open", false ).attr("open"), undefined, "Setting open attribute to false removes it" );
348
+
349
+ $text.attr( "data-something", true );
350
+ equal( $text.attr("data-something"), "true", "Set data attributes");
351
+ equal( $text.data("something"), true, "Setting data attributes are not affected by boolean settings");
352
+ $text.attr( "data-another", false );
353
+ equal( $text.attr("data-another"), "false", "Set data attributes");
354
+ equal( $text.data("another"), false, "Setting data attributes are not affected by boolean settings" );
355
+ equal( $text.attr( "aria-disabled", false ).attr("aria-disabled"), "false", "Setting aria attributes are not affected by boolean settings" );
356
+ $text.removeData("something").removeData("another").removeAttr("aria-disabled");
357
+
358
+ jQuery("#foo").attr("contenteditable", true);
359
+ equal( jQuery("#foo").attr("contenteditable"), "true", "Enumerated attributes are set properly" );
360
+
361
+ var attributeNode = document.createAttribute("irrelevant"),
362
+ commentNode = document.createComment("some comment"),
363
+ textNode = document.createTextNode("some text"),
364
+ obj = {};
365
+
366
+ jQuery.each( [ commentNode, textNode, attributeNode ], function( i, elem ) {
367
+ var $elem = jQuery( elem );
368
+ $elem.attr( "nonexisting", "foo" );
369
+ strictEqual( $elem.attr("nonexisting"), undefined, "attr(name, value) works correctly on comment and text nodes (bug #7500)." );
370
+ });
371
+
372
+ // Register the property name to avoid generating a new global when testing window
373
+ Globals.register("nonexisting");
374
+ jQuery.each( [ window, document, obj, "#firstp" ], function( i, elem ) {
375
+ var oldVal = elem.nonexisting,
376
+ $elem = jQuery( elem );
377
+ strictEqual( $elem.attr("nonexisting"), undefined, "attr works correctly for non existing attributes (bug #7500)." );
378
+ equal( $elem.attr( "nonexisting", "foo" ).attr("nonexisting"), "foo", "attr falls back to prop on unsupported arguments" );
379
+ elem.nonexisting = oldVal;
380
+ });
381
+
382
+ var table = jQuery("#table").append("<tr><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr>"),
383
+ td = table.find("td:first");
384
+ td.attr( "rowspan", "2" );
385
+ equal( td[ 0 ]["rowSpan"], 2, "Check rowspan is correctly set" );
386
+ td.attr( "colspan", "2" );
387
+ equal( td[ 0 ]["colSpan"], 2, "Check colspan is correctly set" );
388
+ table.attr("cellspacing", "2");
389
+ equal( table[ 0 ]["cellSpacing"], "2", "Check cellspacing is correctly set" );
390
+
391
+ equal( jQuery("#area1").attr("value"), undefined, "Value attribute is distinct from value property." );
392
+
393
+ // for #1070
394
+ jQuery("#name").attr( "someAttr", "0" );
395
+ equal( jQuery("#name").attr("someAttr"), "0", "Set attribute to a string of '0'" );
396
+ jQuery("#name").attr( "someAttr", 0 );
397
+ equal( jQuery("#name").attr("someAttr"), "0", "Set attribute to the number 0" );
398
+ jQuery("#name").attr( "someAttr", 1 );
399
+ equal( jQuery("#name").attr("someAttr"), "1", "Set attribute to the number 1" );
400
+
401
+ // using contents will get comments regular, text, and comment nodes
402
+ var j = jQuery("#nonnodes").contents();
403
+
404
+ j.attr( "name", "attrvalue" );
405
+ equal( j.attr("name"), "attrvalue", "Check node,textnode,comment for attr" );
406
+ j.removeAttr("name");
407
+
408
+ // Type
409
+ var type = jQuery("#check2").attr("type");
410
+ try {
411
+ jQuery("#check2").attr( "type", "hidden" );
412
+ ok( true, "No exception thrown on input type change" );
413
+ } catch( e ) {
414
+ ok( true, "Exception thrown on input type change: " + e );
415
+ }
416
+
417
+ var check = document.createElement("input");
418
+ var thrown = true;
419
+ try {
420
+ jQuery( check ).attr( "type", "checkbox" );
421
+ } catch( e ) {
422
+ thrown = false;
423
+ }
424
+ ok( thrown, "Exception thrown when trying to change type property" );
425
+ equal( "checkbox", jQuery( check ).attr("type"), "Verify that you can change the type of an input element that isn't in the DOM" );
426
+
427
+ check = jQuery("<input />");
428
+ thrown = true;
429
+ try {
430
+ check.attr( "type", "checkbox" );
431
+ } catch( e ) {
432
+ thrown = false;
433
+ }
434
+ ok( thrown, "Exception thrown when trying to change type property" );
435
+ equal( "checkbox", check.attr("type"), "Verify that you can change the type of an input element that isn't in the DOM" );
436
+
437
+ var button = jQuery("#button");
438
+ try {
439
+ button.attr( "type", "submit" );
440
+ ok( true, "No exception thrown on button type change" );
441
+ } catch( e ) {
442
+ ok( true, "Exception thrown on button type change: " + e );
443
+ }
444
+
445
+ var $radio = jQuery( "<input>", {
446
+ "value": "sup",
447
+ "type": "radio"
448
+ }).appendTo("#testForm");
449
+ equal( $radio.val(), "sup", "Value is not reset when type is set after value on a radio" );
450
+
451
+ // Setting attributes on svg elements (bug #3116)
452
+ var $svg = jQuery(
453
+ "<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' baseProfile='full' width='200' height='200'>" +
454
+
455
+ "<circle cx='200' cy='200' r='150' />" +
456
+ "</svg>"
457
+ ).appendTo("body");
458
+ equal( $svg.attr( "cx", 100 ).attr("cx"), "100", "Set attribute on svg element" );
459
+ $svg.remove();
460
+
461
+ // undefined values are chainable
462
+ jQuery("#name").attr( "maxlength", "5" ).removeAttr("nonexisting");
463
+ equal( typeof jQuery("#name").attr( "maxlength", undefined ), "object", ".attr('attribute', undefined) is chainable (#5571)" );
464
+ equal( jQuery("#name").attr( "maxlength", undefined ).attr("maxlength"), "5", ".attr('attribute', undefined) does not change value (#5571)" );
465
+ equal( jQuery("#name").attr( "nonexisting", undefined ).attr("nonexisting"), undefined, ".attr('attribute', undefined) does not create attribute (#5571)" );
466
+ });
467
+
468
+ test( "attr(String, Object) - Loaded via XML document", function() {
469
+ expect( 2 );
470
+ var xml = createDashboardXML();
471
+ var titles = [];
472
+ jQuery( "tab", xml ).each(function() {
473
+ titles.push( jQuery( this ).attr("title") );
474
+ });
475
+ equal( titles[ 0 ], "Location", "attr() in XML context: Check first title" );
476
+ equal( titles[ 1 ], "Users", "attr() in XML context: Check second title" );
477
+ });
478
+
479
+ test( "attr(String, Object) - Loaded via XML fragment", function() {
480
+ expect( 2 );
481
+ var frag = createXMLFragment(),
482
+ $frag = jQuery( frag );
483
+
484
+ $frag.attr( "test", "some value" );
485
+ equal( $frag.attr("test"), "some value", "set attribute" );
486
+ $frag.attr( "test", null );
487
+ equal( $frag.attr("test"), undefined, "remove attribute" );
488
+ });
489
+
490
+ test( "attr('tabindex')", function() {
491
+ expect( 8 );
492
+
493
+ // elements not natively tabbable
494
+ equal( jQuery("#listWithTabIndex").attr("tabindex"), "5", "not natively tabbable, with tabindex set to 0" );
495
+ equal( jQuery("#divWithNoTabIndex").attr("tabindex"), undefined, "not natively tabbable, no tabindex set" );
496
+
497
+ // anchor with href
498
+ equal( jQuery("#linkWithNoTabIndex").attr("tabindex"), undefined, "anchor with href, no tabindex set" );
499
+ equal( jQuery("#linkWithTabIndex").attr("tabindex"), "2", "anchor with href, tabindex set to 2" );
500
+ equal( jQuery("#linkWithNegativeTabIndex").attr("tabindex"), "-1", "anchor with href, tabindex set to -1" );
501
+
502
+ // anchor without href
503
+ equal( jQuery("#linkWithNoHrefWithNoTabIndex").attr("tabindex"), undefined, "anchor without href, no tabindex set" );
504
+ equal( jQuery("#linkWithNoHrefWithTabIndex").attr("tabindex"), "1", "anchor without href, tabindex set to 2" );
505
+ equal( jQuery("#linkWithNoHrefWithNegativeTabIndex").attr("tabindex"), "-1", "anchor without href, no tabindex set" );
506
+ });
507
+
508
+ test( "attr('tabindex', value)", function() {
509
+ expect( 9 );
510
+
511
+ var element = jQuery("#divWithNoTabIndex");
512
+ equal( element.attr("tabindex"), undefined, "start with no tabindex" );
513
+
514
+ // set a positive string
515
+ element.attr( "tabindex", "1" );
516
+ equal( element.attr("tabindex"), "1", "set tabindex to 1 (string)" );
517
+
518
+ // set a zero string
519
+ element.attr( "tabindex", "0" );
520
+ equal( element.attr("tabindex"), "0", "set tabindex to 0 (string)" );
521
+
522
+ // set a negative string
523
+ element.attr( "tabindex", "-1" );
524
+ equal( element.attr("tabindex"), "-1", "set tabindex to -1 (string)" );
525
+
526
+ // set a positive number
527
+ element.attr( "tabindex", 1 );
528
+ equal( element.attr("tabindex"), "1", "set tabindex to 1 (number)" );
529
+
530
+ // set a zero number
531
+ element.attr( "tabindex", 0 );
532
+ equal(element.attr("tabindex"), "0", "set tabindex to 0 (number)");
533
+
534
+ // set a negative number
535
+ element.attr( "tabindex", -1 );
536
+ equal( element.attr("tabindex"), "-1", "set tabindex to -1 (number)" );
537
+
538
+ element = jQuery("#linkWithTabIndex");
539
+ equal( element.attr("tabindex"), "2", "start with tabindex 2" );
540
+
541
+ element.attr( "tabindex", -1 );
542
+ equal( element.attr("tabindex"), "-1", "set negative tabindex" );
543
+ });
544
+
545
+ test( "removeAttr(String)", function() {
546
+ expect( 12 );
547
+ var $first;
548
+
549
+ equal( jQuery("#mark").removeAttr("class").attr("class"), undefined, "remove class" );
550
+ equal( jQuery("#form").removeAttr("id").attr("id"), undefined, "Remove id" );
551
+ equal( jQuery("#foo").attr( "style", "position:absolute;" ).removeAttr("style").attr("style"), undefined, "Check removing style attribute" );
552
+ equal( jQuery("#form").attr( "style", "position:absolute;" ).removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" );
553
+ equal( jQuery("<div style='position: absolute'></div>").appendTo("#foo").removeAttr("style").prop("style").cssText, "", "Check removing style attribute (#9699 Webkit)" );
554
+ equal( jQuery("#fx-test-group").attr( "height", "3px" ).removeAttr("height").get( 0 ).style.height, "1px", "Removing height attribute has no effect on height set with style attribute" );
555
+
556
+ jQuery("#check1").removeAttr("checked").prop( "checked", true ).removeAttr("checked");
557
+ equal( document.getElementById("check1").checked, false, "removeAttr sets boolean properties to false" );
558
+ jQuery("#text1").prop( "readOnly", true ).removeAttr("readonly");
559
+ equal( document.getElementById("text1").readOnly, false, "removeAttr sets boolean properties to false" );
560
+
561
+ jQuery("#option2c").removeAttr("selected");
562
+ equal( jQuery("#option2d").attr("selected"), "selected", "Removing `selected` from an option that is not selected does not remove selected from the currently selected option (#10870)" );
563
+
564
+ try {
565
+ $first = jQuery("#first").attr( "contenteditable", "true" ).removeAttr("contenteditable");
566
+ equal( $first.attr("contenteditable"), undefined, "Remove the contenteditable attribute" );
567
+ } catch( e ) {
568
+ ok( false, "Removing contenteditable threw an error (#10429)" );
569
+ }
570
+
571
+ $first = jQuery("<div Case='mixed'></div>");
572
+ equal( $first.attr("Case"), "mixed", "case of attribute doesn't matter" );
573
+ $first.removeAttr("Case");
574
+ // IE 6/7 return empty string here, not undefined
575
+ ok( !$first.attr("Case"), "mixed-case attribute was removed" );
576
+ });
577
+
578
+ test( "removeAttr(String) in XML", function() {
579
+ expect( 7 );
580
+ var xml = createDashboardXML(),
581
+ iwt = jQuery( "infowindowtab", xml );
582
+
583
+ equal( iwt.attr("normal"), "ab", "Check initial value" );
584
+ iwt.removeAttr("Normal");
585
+ equal( iwt.attr("normal"), "ab", "Should still be there" );
586
+ iwt.removeAttr("normal");
587
+ equal( iwt.attr("normal"), undefined, "Removed" );
588
+
589
+ equal( iwt.attr("mixedCase"), "yes", "Check initial value" );
590
+ equal( iwt.attr("mixedcase"), undefined, "toLowerCase not work good" );
591
+ iwt.removeAttr("mixedcase");
592
+ equal( iwt.attr("mixedCase"), "yes", "Should still be there" );
593
+ iwt.removeAttr("mixedCase");
594
+ equal( iwt.attr("mixedCase"), undefined, "Removed" );
595
+ });
596
+
597
+ test( "removeAttr(Multi String, variable space width)", function() {
598
+ expect( 8 );
599
+
600
+ var div = jQuery("<div id='a' alt='b' title='c' rel='d'></div>"),
601
+ tests = {
602
+ id: "a",
603
+ alt: "b",
604
+ title: "c",
605
+ rel: "d"
606
+ };
607
+
608
+ jQuery.each( tests, function( key, val ) {
609
+ equal( div.attr( key ), val, "Attribute `" + key + "` exists, and has a value of `" + val + "`" );
610
+ });
611
+
612
+ div.removeAttr( "id alt title rel " );
613
+
614
+ jQuery.each( tests, function( key, val ) {
615
+ equal( div.attr( key ), undefined, "Attribute `" + key + "` was removed" );
616
+ });
617
+ });
618
+
619
+ test( "prop(String, Object)", function() {
620
+ expect( 31 );
621
+
622
+ equal( jQuery("#text1").prop("value"), "Test", "Check for value attribute" );
623
+ equal( jQuery("#text1").prop( "value", "Test2" ).prop("defaultValue"), "Test", "Check for defaultValue attribute" );
624
+ equal( jQuery("#select2").prop("selectedIndex"), 3, "Check for selectedIndex attribute" );
625
+ equal( jQuery("#foo").prop("nodeName").toUpperCase(), "DIV", "Check for nodeName attribute" );
626
+ equal( jQuery("#foo").prop("tagName").toUpperCase(), "DIV", "Check for tagName attribute" );
627
+ equal( jQuery("<option/>").prop("selected"), false, "Check selected attribute on disconnected element." );
628
+
629
+ equal( jQuery("#listWithTabIndex").prop("tabindex"), 5, "Check retrieving tabindex" );
630
+ jQuery("#text1").prop( "readonly", true );
631
+ equal( document.getElementById("text1").readOnly, true, "Check setting readOnly property with 'readonly'" );
632
+ equal( jQuery("#label-for").prop("for"), "action", "Check retrieving htmlFor" );
633
+ jQuery("#text1").prop("class", "test");
634
+ equal( document.getElementById("text1").className, "test", "Check setting className with 'class'" );
635
+ equal( jQuery("#text1").prop("maxlength"), 30, "Check retrieving maxLength" );
636
+ jQuery("#table").prop( "cellspacing", 1 );
637
+ equal( jQuery("#table").prop("cellSpacing"), "1", "Check setting and retrieving cellSpacing" );
638
+ jQuery("#table").prop( "cellpadding", 1 );
639
+ equal( jQuery("#table").prop("cellPadding"), "1", "Check setting and retrieving cellPadding" );
640
+ jQuery("#table").prop( "rowspan", 1 );
641
+ equal( jQuery("#table").prop("rowSpan"), 1, "Check setting and retrieving rowSpan" );
642
+ jQuery("#table").prop( "colspan", 1 );
643
+ equal( jQuery("#table").prop("colSpan"), 1, "Check setting and retrieving colSpan" );
644
+ jQuery("#table").prop( "usemap", 1 );
645
+ equal( jQuery("#table").prop("useMap"), 1, "Check setting and retrieving useMap" );
646
+ jQuery("#table").prop( "frameborder", 1 );
647
+ equal( jQuery("#table").prop("frameBorder"), 1, "Check setting and retrieving frameBorder" );
648
+ QUnit.reset();
649
+
650
+ var body = document.body,
651
+ $body = jQuery( body );
652
+
653
+ ok( $body.prop("nextSibling") === null, "Make sure a null expando returns null" );
654
+ body["foo"] = "bar";
655
+ equal( $body.prop("foo"), "bar", "Make sure the expando is preferred over the dom attribute" );
656
+ body["foo"] = undefined;
657
+ ok( $body.prop("foo") === undefined, "Make sure the expando is preferred over the dom attribute, even if undefined" );
658
+
659
+ var select = document.createElement("select"),
660
+ optgroup = document.createElement("optgroup"),
661
+ option = document.createElement("option");
662
+
663
+ optgroup.appendChild( option );
664
+ select.appendChild( optgroup );
665
+
666
+ equal( jQuery( option ).prop("selected"), true, "Make sure that a single option is selected, even when in an optgroup." );
667
+ equal( jQuery( document ).prop("nodeName"), "#document", "prop works correctly on document nodes (bug #7451)." );
668
+
669
+ var attributeNode = document.createAttribute("irrelevant"),
670
+ commentNode = document.createComment("some comment"),
671
+ textNode = document.createTextNode("some text"),
672
+ obj = {};
673
+ jQuery.each( [ document, attributeNode, commentNode, textNode, obj, "#firstp" ], function( i, ele ) {
674
+ strictEqual( jQuery( ele ).prop("nonexisting"), undefined, "prop works correctly for non existing attributes (bug #7500)." );
675
+ });
676
+
677
+ obj = {};
678
+ jQuery.each( [ document, obj ], function( i, ele ) {
679
+ var $ele = jQuery( ele );
680
+ $ele.prop( "nonexisting", "foo" );
681
+ equal( $ele.prop("nonexisting"), "foo", "prop(name, value) works correctly for non existing attributes (bug #7500)." );
682
+ });
683
+ jQuery( document ).removeProp("nonexisting");
684
+
685
+ var $form = jQuery("#form").prop( "enctype", "multipart/form-data" );
686
+ equal( $form.prop("enctype"), "multipart/form-data", "Set the enctype of a form (encoding in IE6/7 #6743)" );
687
+ });
688
+
689
+ test( "prop('tabindex')", function() {
690
+ expect( 8 );
691
+
692
+ // elements not natively tabbable
693
+ equal( jQuery("#listWithTabIndex").prop("tabindex"), 5, "not natively tabbable, with tabindex set to 0" );
694
+ equal( jQuery("#divWithNoTabIndex").prop("tabindex"), undefined, "not natively tabbable, no tabindex set" );
695
+
696
+ // anchor with href
697
+ equal( jQuery("#linkWithNoTabIndex").prop("tabindex"), 0, "anchor with href, no tabindex set" );
698
+ equal( jQuery("#linkWithTabIndex").prop("tabindex"), 2, "anchor with href, tabindex set to 2" );
699
+ equal( jQuery("#linkWithNegativeTabIndex").prop("tabindex"), -1, "anchor with href, tabindex set to -1" );
700
+
701
+ // anchor without href
702
+ equal( jQuery("#linkWithNoHrefWithNoTabIndex").prop("tabindex"), undefined, "anchor without href, no tabindex set" );
703
+ equal( jQuery("#linkWithNoHrefWithTabIndex").prop("tabindex"), 1, "anchor without href, tabindex set to 2" );
704
+ equal( jQuery("#linkWithNoHrefWithNegativeTabIndex").prop("tabindex"), -1, "anchor without href, no tabindex set" );
705
+ });
706
+
707
+ test( "prop('tabindex', value)", 10, function() {
708
+
709
+ var clone,
710
+ element = jQuery("#divWithNoTabIndex");
711
+
712
+ equal( element.prop("tabindex"), undefined, "start with no tabindex" );
713
+
714
+ // set a positive string
715
+ element.prop( "tabindex", "1" );
716
+ equal( element.prop("tabindex"), 1, "set tabindex to 1 (string)" );
717
+
718
+ // set a zero string
719
+ element.prop( "tabindex", "0" );
720
+ equal( element.prop("tabindex"), 0, "set tabindex to 0 (string)" );
721
+
722
+ // set a negative string
723
+ element.prop( "tabindex", "-1" );
724
+ equal( element.prop("tabindex"), -1, "set tabindex to -1 (string)" );
725
+
726
+ // set a positive number
727
+ element.prop( "tabindex", 1 );
728
+ equal( element.prop("tabindex"), 1, "set tabindex to 1 (number)" );
729
+
730
+ // set a zero number
731
+ element.prop( "tabindex", 0 );
732
+ equal( element.prop("tabindex"), 0, "set tabindex to 0 (number)" );
733
+
734
+ // set a negative number
735
+ element.prop( "tabindex", -1 );
736
+ equal( element.prop("tabindex"), -1, "set tabindex to -1 (number)" );
737
+
738
+ element = jQuery("#linkWithTabIndex");
739
+ equal( element.prop("tabindex"), 2, "start with tabindex 2" );
740
+
741
+ element.prop( "tabindex", -1 );
742
+ equal( element.prop("tabindex"), -1, "set negative tabindex" );
743
+
744
+ clone = element.clone();
745
+ clone.prop( "tabindex", 1 );
746
+ equal( clone[ 0 ].getAttribute("tabindex"), "1", "set tabindex on cloned element" );
747
+ });
748
+
749
+ test( "removeProp(String)", function() {
750
+ expect( 6 );
751
+ var attributeNode = document.createAttribute("irrelevant"),
752
+ commentNode = document.createComment("some comment"),
753
+ textNode = document.createTextNode("some text"),
754
+ obj = {};
755
+
756
+ strictEqual(
757
+ jQuery( "#firstp" ).prop( "nonexisting", "foo" ).removeProp( "nonexisting" )[ 0 ]["nonexisting"],
758
+ undefined,
759
+ "removeprop works correctly on DOM element nodes"
760
+ );
761
+
762
+ jQuery.each( [ document, obj ], function( i, ele ) {
763
+ var $ele = jQuery( ele );
764
+ $ele.prop( "nonexisting", "foo" ).removeProp("nonexisting");
765
+ strictEqual( ele["nonexisting"], undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." );
766
+ });
767
+ jQuery.each( [ commentNode, textNode, attributeNode ], function( i, ele ) {
768
+ var $ele = jQuery( ele );
769
+ $ele.prop( "nonexisting", "foo" ).removeProp("nonexisting");
770
+ strictEqual( ele["nonexisting"], undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." );
771
+ });
772
+ });
773
+
774
+ test( "val()", function() {
775
+ expect( 21 + ( jQuery.fn.serialize ? 6 : 0 ) );
776
+
777
+ document.getElementById("text1").value = "bla";
778
+ equal( jQuery("#text1").val(), "bla", "Check for modified value of input element" );
779
+
780
+ QUnit.reset();
781
+
782
+ equal( jQuery("#text1").val(), "Test", "Check for value of input element" );
783
+ // ticket #1714 this caused a JS error in IE
784
+ equal( jQuery("#first").val(), "", "Check a paragraph element to see if it has a value" );
785
+ ok( jQuery([]).val() === undefined, "Check an empty jQuery object will return undefined from val" );
786
+
787
+ equal( jQuery("#select2").val(), "3", "Call val() on a single='single' select" );
788
+
789
+ deepEqual( jQuery("#select3").val(), [ "1", "2" ], "Call val() on a multiple='multiple' select" );
790
+
791
+ equal( jQuery("#option3c").val(), "2", "Call val() on a option element with value" );
792
+
793
+ equal( jQuery("#option3a").val(), "", "Call val() on a option element with empty value" );
794
+
795
+ equal( jQuery("#option3e").val(), "no value", "Call val() on a option element with no value attribute" );
796
+
797
+ equal( jQuery("#option3a").val(), "", "Call val() on a option element with no value attribute" );
798
+
799
+ jQuery("#select3").val("");
800
+ deepEqual( jQuery("#select3").val(), [""], "Call val() on a multiple='multiple' select" );
801
+
802
+ deepEqual( jQuery("#select4").val(), [], "Call val() on multiple='multiple' select with all disabled options" );
803
+
804
+ jQuery("#select4 optgroup").add("#select4 > [disabled]").attr( "disabled", false );
805
+ deepEqual( jQuery("#select4").val(), [ "2", "3" ], "Call val() on multiple='multiple' select with some disabled options" );
806
+
807
+ jQuery("#select4").attr( "disabled", true );
808
+ deepEqual( jQuery("#select4").val(), [ "2", "3" ], "Call val() on disabled multiple='multiple' select" );
809
+
810
+ equal( jQuery("#select5").val(), "3", "Check value on ambiguous select." );
811
+
812
+ jQuery("#select5").val( 1 );
813
+ equal( jQuery("#select5").val(), "1", "Check value on ambiguous select." );
814
+
815
+ jQuery("#select5").val( 3 );
816
+ equal( jQuery("#select5").val(), "3", "Check value on ambiguous select." );
817
+
818
+ strictEqual(
819
+ jQuery("<select name='select12584' id='select12584'><option value='1' disabled='disabled'>1</option></select>").val(),
820
+ null,
821
+ "Select-one with only option disabled (#12584)"
822
+ );
823
+
824
+ if ( jQuery.fn.serialize ) {
825
+ var checks = jQuery("<input type='checkbox' name='test' value='1'/><input type='checkbox' name='test' value='2'/><input type='checkbox' name='test' value=''/><input type='checkbox' name='test'/>").appendTo("#form");
826
+
827
+ deepEqual( checks.serialize(), "", "Get unchecked values." );
828
+
829
+ equal( checks.eq( 3 ).val(), "on", "Make sure a value of 'on' is provided if none is specified." );
830
+
831
+ checks.val([ "2" ]);
832
+ deepEqual( checks.serialize(), "test=2", "Get a single checked value." );
833
+
834
+ checks.val([ "1", "" ]);
835
+ deepEqual( checks.serialize(), "test=1&test=", "Get multiple checked values." );
836
+
837
+ checks.val([ "", "2" ]);
838
+ deepEqual( checks.serialize(), "test=2&test=", "Get multiple checked values." );
839
+
840
+ checks.val([ "1", "on" ]);
841
+ deepEqual( checks.serialize(), "test=1&test=on", "Get multiple checked values." );
842
+
843
+ checks.remove();
844
+ }
845
+
846
+ var $button = jQuery("<button value='foobar'>text</button>").insertAfter("#button");
847
+ equal( $button.val(), "foobar", "Value retrieval on a button does not return innerHTML" );
848
+ equal( $button.val("baz").html(), "text", "Setting the value does not change innerHTML" );
849
+
850
+ equal( jQuery("<option/>").val("test").attr("value"), "test", "Setting value sets the value attribute" );
851
+ });
852
+
853
+ if ( "value" in document.createElement("meter") &&
854
+ "value" in document.createElement("progress") ) {
855
+
856
+ test( "val() respects numbers without exception (Bug #9319)", function() {
857
+
858
+ expect( 4 );
859
+
860
+ var $meter = jQuery("<meter min='0' max='10' value='5.6'></meter>"),
861
+ $progress = jQuery("<progress max='10' value='1.5'></progress>");
862
+
863
+ try {
864
+ equal( typeof $meter.val(), "number", "meter, returns a number and does not throw exception" );
865
+ equal( $meter.val(), $meter[ 0 ].value, "meter, api matches host and does not throw exception" );
866
+
867
+ equal( typeof $progress.val(), "number", "progress, returns a number and does not throw exception" );
868
+ equal( $progress.val(), $progress[ 0 ].value, "progress, api matches host and does not throw exception" );
869
+
870
+ } catch( e ) {}
871
+
872
+ $meter.remove();
873
+ $progress.remove();
874
+ });
875
+ }
876
+
877
+ var testVal = function( valueObj ) {
878
+ expect( 8 );
879
+
880
+ QUnit.reset();
881
+ jQuery("#text1").val( valueObj("test") );
882
+ equal( document.getElementById("text1").value, "test", "Check for modified (via val(String)) value of input element" );
883
+
884
+ jQuery("#text1").val( valueObj( undefined ) );
885
+ equal( document.getElementById("text1").value, "", "Check for modified (via val(undefined)) value of input element" );
886
+
887
+ jQuery("#text1").val( valueObj( 67 ) );
888
+ equal( document.getElementById("text1").value, "67", "Check for modified (via val(Number)) value of input element" );
889
+
890
+ jQuery("#text1").val( valueObj( null ) );
891
+ equal( document.getElementById("text1").value, "", "Check for modified (via val(null)) value of input element" );
892
+
893
+ var $select1 = jQuery("#select1");
894
+ $select1.val( valueObj("3") );
895
+ equal( $select1.val(), "3", "Check for modified (via val(String)) value of select element" );
896
+
897
+ $select1.val( valueObj( 2 ) );
898
+ equal( $select1.val(), "2", "Check for modified (via val(Number)) value of select element" );
899
+
900
+ $select1.append("<option value='4'>four</option>");
901
+ $select1.val( valueObj( 4 ) );
902
+ equal( $select1.val(), "4", "Should be possible to set the val() to a newly created option" );
903
+
904
+ // using contents will get comments regular, text, and comment nodes
905
+ var j = jQuery("#nonnodes").contents();
906
+ j.val( valueObj( "asdf" ) );
907
+ equal( j.val(), "asdf", "Check node,textnode,comment with val()" );
908
+ j.removeAttr("value");
909
+ };
910
+
911
+ test( "val(String/Number)", function() {
912
+ testVal( bareObj );
913
+ });
914
+
915
+ test( "val(Function)", function() {
916
+ testVal( functionReturningObj );
917
+ });
918
+
919
+ test( "val(Array of Numbers) (Bug #7123)", function() {
920
+ expect( 4 );
921
+ jQuery("#form").append("<input type='checkbox' name='arrayTest' value='1' /><input type='checkbox' name='arrayTest' value='2' /><input type='checkbox' name='arrayTest' value='3' checked='checked' /><input type='checkbox' name='arrayTest' value='4' />");
922
+ var elements = jQuery("input[name=arrayTest]").val([ 1, 2 ]);
923
+ ok( elements[ 0 ].checked, "First element was checked" );
924
+ ok( elements[ 1 ].checked, "Second element was checked" );
925
+ ok( !elements[ 2 ].checked, "Third element was unchecked" );
926
+ ok( !elements[ 3 ].checked, "Fourth element remained unchecked" );
927
+
928
+ elements.remove();
929
+ });
930
+
931
+ test( "val(Function) with incoming value", function() {
932
+ expect( 10 );
933
+
934
+ QUnit.reset();
935
+ var oldVal = jQuery("#text1").val();
936
+
937
+ jQuery("#text1").val(function( i, val ) {
938
+ equal( val, oldVal, "Make sure the incoming value is correct." );
939
+ return "test";
940
+ });
941
+
942
+ equal( document.getElementById("text1").value, "test", "Check for modified (via val(String)) value of input element" );
943
+
944
+ oldVal = jQuery("#text1").val();
945
+
946
+ jQuery("#text1").val(function( i, val ) {
947
+ equal( val, oldVal, "Make sure the incoming value is correct." );
948
+ return 67;
949
+ });
950
+
951
+ equal( document.getElementById("text1").value, "67", "Check for modified (via val(Number)) value of input element" );
952
+
953
+ oldVal = jQuery("#select1").val();
954
+
955
+ jQuery("#select1").val(function( i, val ) {
956
+ equal( val, oldVal, "Make sure the incoming value is correct." );
957
+ return "3";
958
+ });
959
+
960
+ equal( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" );
961
+
962
+ oldVal = jQuery("#select1").val();
963
+
964
+ jQuery("#select1").val(function( i, val ) {
965
+ equal( val, oldVal, "Make sure the incoming value is correct." );
966
+ return 2;
967
+ });
968
+
969
+ equal( jQuery("#select1").val(), "2", "Check for modified (via val(Number)) value of select element" );
970
+
971
+ jQuery("#select1").append("<option value='4'>four</option>");
972
+
973
+ oldVal = jQuery("#select1").val();
974
+
975
+ jQuery("#select1").val(function( i, val ) {
976
+ equal( val, oldVal, "Make sure the incoming value is correct." );
977
+ return 4;
978
+ });
979
+
980
+ equal( jQuery("#select1").val(), "4", "Should be possible to set the val() to a newly created option" );
981
+ });
982
+
983
+ // testing if a form.reset() breaks a subsequent call to a select element's .val() (in IE only)
984
+ test( "val(select) after form.reset() (Bug #2551)", function() {
985
+ expect( 3 );
986
+
987
+ jQuery("<form id='kk' name='kk'><select id='kkk'><option value='cf'>cf</option><option value='gf'>gf</option></select></form>").appendTo("#qunit-fixture");
988
+
989
+ jQuery("#kkk").val("gf");
990
+
991
+ document["kk"].reset();
992
+
993
+ equal( jQuery("#kkk")[ 0 ].value, "cf", "Check value of select after form reset." );
994
+ equal( jQuery("#kkk").val(), "cf", "Check value of select after form reset." );
995
+
996
+ // re-verify the multi-select is not broken (after form.reset) by our fix for single-select
997
+ deepEqual( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple='multiple' select" );
998
+
999
+ jQuery("#kk").remove();
1000
+ });
1001
+
1002
+ var testAddClass = function( valueObj ) {
1003
+ expect( 9 );
1004
+
1005
+ var div = jQuery("#qunit-fixture div");
1006
+ div.addClass( valueObj("test") );
1007
+ var pass = true;
1008
+ for ( var i = 0; i < div.size(); i++ ) {
1009
+ if ( !~div.get( i ).className.indexOf("test") ) {
1010
+ pass = false;
1011
+ }
1012
+ }
1013
+ ok( pass, "Add Class" );
1014
+
1015
+ // using contents will get regular, text, and comment nodes
1016
+ var j = jQuery("#nonnodes").contents();
1017
+ j.addClass( valueObj("asdf") );
1018
+ ok( j.hasClass("asdf"), "Check node,textnode,comment for addClass" );
1019
+
1020
+ div = jQuery("<div/>");
1021
+
1022
+ div.addClass( valueObj("test") );
1023
+ equal( div.attr("class"), "test", "Make sure there's no extra whitespace." );
1024
+
1025
+ div.attr( "class", " foo" );
1026
+ div.addClass( valueObj("test") );
1027
+ equal( div.attr("class"), "foo test", "Make sure there's no extra whitespace." );
1028
+
1029
+ div.attr( "class", "foo" );
1030
+ div.addClass( valueObj("bar baz") );
1031
+ equal( div.attr("class"), "foo bar baz", "Make sure there isn't too much trimming." );
1032
+
1033
+ div.removeClass();
1034
+ div.addClass( valueObj("foo") ).addClass( valueObj("foo") );
1035
+ equal( div.attr("class"), "foo", "Do not add the same class twice in separate calls." );
1036
+
1037
+ div.addClass( valueObj("fo") );
1038
+ equal( div.attr("class"), "foo fo", "Adding a similar class does not get interrupted." );
1039
+ div.removeClass().addClass("wrap2");
1040
+ ok( div.addClass("wrap").hasClass("wrap"), "Can add similarly named classes");
1041
+
1042
+ div.removeClass();
1043
+ div.addClass( valueObj("bar bar") );
1044
+ equal( div.attr("class"), "bar", "Do not add the same class twice in the same call." );
1045
+ };
1046
+
1047
+ test( "addClass(String)", function() {
1048
+ testAddClass( bareObj );
1049
+ });
1050
+
1051
+ test( "addClass(Function)", function() {
1052
+ testAddClass( functionReturningObj );
1053
+ });
1054
+
1055
+ test( "addClass(Function) with incoming value", function() {
1056
+ expect( 52 );
1057
+ var div = jQuery("#qunit-fixture div"),
1058
+ old = div.map(function() {
1059
+ return jQuery(this).attr("class") || "";
1060
+ });
1061
+
1062
+ div.addClass(function( i, val ) {
1063
+ if ( this.id !== "_firebugConsole" ) {
1064
+ equal( val, old[ i ], "Make sure the incoming value is correct." );
1065
+ return "test";
1066
+ }
1067
+ });
1068
+
1069
+ var pass = true;
1070
+ for ( var i = 0; i < div.length; i++ ) {
1071
+ if ( div.get(i).className.indexOf("test") == -1 ) {
1072
+ pass = false;
1073
+ }
1074
+ }
1075
+ ok( pass, "Add Class" );
1076
+ });
1077
+
1078
+ var testRemoveClass = function(valueObj) {
1079
+ expect( 8 );
1080
+
1081
+ var $set = jQuery("#qunit-fixture div"),
1082
+ div = document.createElement("div");
1083
+
1084
+ $set.addClass("test").removeClass( valueObj("test") );
1085
+
1086
+ ok( !$set.is(".test"), "Remove Class" );
1087
+
1088
+ $set.addClass("test").addClass("foo").addClass("bar");
1089
+ $set.removeClass( valueObj("test") ).removeClass( valueObj("bar") ).removeClass( valueObj("foo") );
1090
+
1091
+ ok( !$set.is(".test,.bar,.foo"), "Remove multiple classes" );
1092
+
1093
+ // Make sure that a null value doesn't cause problems
1094
+ $set.eq( 0 ).addClass("expected").removeClass( valueObj( null ) );
1095
+ ok( $set.eq( 0 ).is(".expected"), "Null value passed to removeClass" );
1096
+
1097
+ $set.eq( 0 ).addClass("expected").removeClass( valueObj("") );
1098
+ ok( $set.eq( 0 ).is(".expected"), "Empty string passed to removeClass" );
1099
+
1100
+ // using contents will get regular, text, and comment nodes
1101
+ $set = jQuery("#nonnodes").contents();
1102
+ $set.removeClass( valueObj("asdf") );
1103
+ ok( !$set.hasClass("asdf"), "Check node,textnode,comment for removeClass" );
1104
+
1105
+
1106
+ jQuery( div ).removeClass( valueObj("foo") );
1107
+ strictEqual( jQuery( div ).attr("class"), undefined, "removeClass doesn't create a class attribute" );
1108
+
1109
+ div.className = " test foo ";
1110
+
1111
+ jQuery( div ).removeClass( valueObj("foo") );
1112
+ equal( div.className, "test", "Make sure remaining className is trimmed." );
1113
+
1114
+ div.className = " test ";
1115
+
1116
+ jQuery( div ).removeClass( valueObj("test") );
1117
+ equal( div.className, "", "Make sure there is nothing left after everything is removed." );
1118
+ };
1119
+
1120
+ test( "removeClass(String) - simple", function() {
1121
+ testRemoveClass( bareObj );
1122
+ });
1123
+
1124
+ test( "removeClass(Function) - simple", function() {
1125
+ testRemoveClass( functionReturningObj );
1126
+ });
1127
+
1128
+ test( "removeClass(Function) with incoming value", function() {
1129
+ expect( 52 );
1130
+
1131
+ var $divs = jQuery("#qunit-fixture div").addClass("test"), old = $divs.map(function() {
1132
+ return jQuery( this ).attr("class");
1133
+ });
1134
+
1135
+ $divs.removeClass(function( i, val ) {
1136
+ if ( this.id !== "_firebugConsole" ) {
1137
+ equal( val, old[ i ], "Make sure the incoming value is correct." );
1138
+ return "test";
1139
+ }
1140
+ });
1141
+
1142
+ ok( !$divs.is(".test"), "Remove Class" );
1143
+ });
1144
+
1145
+ test( "removeClass() removes duplicates", function() {
1146
+ expect( 1 );
1147
+
1148
+ var $div = jQuery( jQuery.parseHTML("<div class='x x x'></div>") );
1149
+
1150
+ $div.removeClass("x");
1151
+
1152
+ ok( !$div.hasClass("x"), "Element with multiple same classes does not escape the wrath of removeClass()" );
1153
+ });
1154
+
1155
+ test("removeClass(undefined) is a no-op", function() {
1156
+ expect( 1 );
1157
+
1158
+ var $div = jQuery("<div class='base second'></div>");
1159
+ $div.removeClass( undefined );
1160
+
1161
+ ok( $div.hasClass("base") && $div.hasClass("second"), "Element still has classes after removeClass(undefined)" );
1162
+ });
1163
+
1164
+ var testToggleClass = function(valueObj) {
1165
+ expect( 17 );
1166
+
1167
+ var e = jQuery("#firstp");
1168
+ ok( !e.is(".test"), "Assert class not present" );
1169
+ e.toggleClass( valueObj("test") );
1170
+ ok( e.is(".test"), "Assert class present" );
1171
+ e.toggleClass( valueObj("test") );
1172
+ ok( !e.is(".test"), "Assert class not present" );
1173
+
1174
+ // class name with a boolean
1175
+ e.toggleClass( valueObj("test"), false );
1176
+ ok( !e.is(".test"), "Assert class not present" );
1177
+ e.toggleClass( valueObj("test"), true );
1178
+ ok( e.is(".test"), "Assert class present" );
1179
+ e.toggleClass( valueObj("test"), false );
1180
+ ok( !e.is(".test"), "Assert class not present" );
1181
+
1182
+ // multiple class names
1183
+ e.addClass("testA testB");
1184
+ ok( e.is(".testA.testB"), "Assert 2 different classes present" );
1185
+ e.toggleClass( valueObj("testB testC") );
1186
+ ok( (e.is(".testA.testC") && !e.is(".testB")), "Assert 1 class added, 1 class removed, and 1 class kept" );
1187
+ e.toggleClass( valueObj("testA testC") );
1188
+ ok( (!e.is(".testA") && !e.is(".testB") && !e.is(".testC")), "Assert no class present" );
1189
+
1190
+ // toggleClass storage
1191
+ e.toggleClass( true );
1192
+ ok( e[ 0 ].className === "", "Assert class is empty (data was empty)" );
1193
+ e.addClass("testD testE");
1194
+ ok( e.is(".testD.testE"), "Assert class present" );
1195
+ e.toggleClass();
1196
+ ok( !e.is(".testD.testE"), "Assert class not present" );
1197
+ ok( jQuery._data(e[ 0 ], "__className__") === "testD testE", "Assert data was stored" );
1198
+ e.toggleClass();
1199
+ ok( e.is(".testD.testE"), "Assert class present (restored from data)" );
1200
+ e.toggleClass( false );
1201
+ ok( !e.is(".testD.testE"), "Assert class not present" );
1202
+ e.toggleClass( true );
1203
+ ok( e.is(".testD.testE"), "Assert class present (restored from data)" );
1204
+ e.toggleClass();
1205
+ e.toggleClass( false );
1206
+ e.toggleClass();
1207
+ ok( e.is(".testD.testE"), "Assert class present (restored from data)" );
1208
+
1209
+ // Cleanup
1210
+ e.removeClass("testD");
1211
+ QUnit.expectJqData( e[ 0 ], "__className__" );
1212
+ };
1213
+
1214
+ test( "toggleClass(String|boolean|undefined[, boolean])", function() {
1215
+ testToggleClass( bareObj );
1216
+ });
1217
+
1218
+ test( "toggleClass(Function[, boolean])", function() {
1219
+ testToggleClass( functionReturningObj );
1220
+ });
1221
+
1222
+ test( "toggleClass(Function[, boolean]) with incoming value", function() {
1223
+ expect( 14 );
1224
+
1225
+ var e = jQuery("#firstp"),
1226
+ old = e.attr("class") || "";
1227
+
1228
+ ok( !e.is(".test"), "Assert class not present" );
1229
+
1230
+ e.toggleClass(function( i, val ) {
1231
+ equal( old, val, "Make sure the incoming value is correct." );
1232
+ return "test";
1233
+ });
1234
+ ok( e.is(".test"), "Assert class present" );
1235
+
1236
+ old = e.attr("class");
1237
+
1238
+ e.toggleClass(function( i, val ) {
1239
+ equal( old, val, "Make sure the incoming value is correct." );
1240
+ return "test";
1241
+ });
1242
+ ok( !e.is(".test"), "Assert class not present" );
1243
+
1244
+ old = e.attr("class") || "";
1245
+
1246
+ // class name with a boolean
1247
+ e.toggleClass(function( i, val, state ) {
1248
+ equal( old, val, "Make sure the incoming value is correct." );
1249
+ equal( state, false, "Make sure that the state is passed in." );
1250
+ return "test";
1251
+ }, false );
1252
+ ok( !e.is(".test"), "Assert class not present" );
1253
+
1254
+ old = e.attr("class") || "";
1255
+
1256
+ e.toggleClass(function( i, val, state ) {
1257
+ equal( old, val, "Make sure the incoming value is correct." );
1258
+ equal( state, true, "Make sure that the state is passed in." );
1259
+ return "test";
1260
+ }, true );
1261
+ ok( e.is(".test"), "Assert class present" );
1262
+
1263
+ old = e.attr("class");
1264
+
1265
+ e.toggleClass(function( i, val, state ) {
1266
+ equal( old, val, "Make sure the incoming value is correct." );
1267
+ equal( state, false, "Make sure that the state is passed in." );
1268
+ return "test";
1269
+ }, false );
1270
+ ok( !e.is(".test"), "Assert class not present" );
1271
+ });
1272
+
1273
+ test( "addClass, removeClass, hasClass", function() {
1274
+ expect( 17 );
1275
+
1276
+ var jq = jQuery("<p>Hi</p>"), x = jq[ 0 ];
1277
+
1278
+ jq.addClass("hi");
1279
+ equal( x.className, "hi", "Check single added class" );
1280
+
1281
+ jq.addClass("foo bar");
1282
+ equal( x.className, "hi foo bar", "Check more added classes" );
1283
+
1284
+ jq.removeClass();
1285
+ equal( x.className, "", "Remove all classes" );
1286
+
1287
+ jq.addClass("hi foo bar");
1288
+ jq.removeClass("foo");
1289
+ equal( x.className, "hi bar", "Check removal of one class" );
1290
+
1291
+ ok( jq.hasClass("hi"), "Check has1" );
1292
+ ok( jq.hasClass("bar"), "Check has2" );
1293
+
1294
+ jq = jQuery("<p class='class1\nclass2\tcla.ss3\n\rclass4'></p>");
1295
+
1296
+ ok( jq.hasClass("class1"), "Check hasClass with line feed" );
1297
+ ok( jq.is(".class1"), "Check is with line feed" );
1298
+ ok( jq.hasClass("class2"), "Check hasClass with tab" );
1299
+ ok( jq.is(".class2"), "Check is with tab" );
1300
+ ok( jq.hasClass("cla.ss3"), "Check hasClass with dot" );
1301
+ ok( jq.hasClass("class4"), "Check hasClass with carriage return" );
1302
+ ok( jq.is(".class4"), "Check is with carriage return" );
1303
+
1304
+ jq.removeClass("class2");
1305
+ ok( jq.hasClass("class2") === false, "Check the class has been properly removed" );
1306
+ jq.removeClass("cla");
1307
+ ok( jq.hasClass("cla.ss3"), "Check the dotted class has not been removed" );
1308
+ jq.removeClass("cla.ss3");
1309
+ ok( jq.hasClass("cla.ss3") === false, "Check the dotted class has been removed" );
1310
+ jq.removeClass("class4");
1311
+ ok( jq.hasClass("class4") === false, "Check the class has been properly removed" );
1312
+ });
1313
+
1314
+ test( "contents().hasClass() returns correct values", function() {
1315
+ expect( 2 );
1316
+
1317
+ var $div = jQuery("<div><span class='foo'></span><!-- comment -->text</div>"),
1318
+ $contents = $div.contents();
1319
+
1320
+ ok( $contents.hasClass("foo"), "Found 'foo' in $contents" );
1321
+ ok( !$contents.hasClass("undefined"), "Did not find 'undefined' in $contents (correctly)" );
1322
+ });
1323
+
1324
+ test( "coords returns correct values in IE6/IE7, see #10828", function() {
1325
+ expect( 1 );
1326
+
1327
+ var area,
1328
+ map = jQuery("<map />");
1329
+
1330
+ area = map.html("<area shape='rect' coords='0,0,0,0' href='#' alt='a' />").find("area");
1331
+ equal( area.attr("coords"), "0,0,0,0", "did not retrieve coords correctly" );
1332
+ });