yellow-brick-road 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. data/README.rst +148 -0
  2. data/Rakefile +37 -0
  3. data/lib/tasks/yellow-brick-road_tasks.rake +4 -0
  4. data/lib/yellow-brick-road.rb +6 -0
  5. data/lib/yellow-brick-road/config.rb +15 -0
  6. data/lib/yellow-brick-road/directive_processor.rb +68 -0
  7. data/lib/yellow-brick-road/engine.rb +22 -0
  8. data/lib/yellow-brick-road/soy_processor.rb +56 -0
  9. data/lib/yellow-brick-road/utils.rb +38 -0
  10. data/lib/yellow-brick-road/version.rb +3 -0
  11. data/test/dummy/Rakefile +7 -0
  12. data/test/dummy/app/assets/javascripts/application.js +12 -0
  13. data/test/dummy/app/assets/javascripts/closure-deps.js +4 -0
  14. data/test/dummy/app/assets/javascripts/my-closure/simple.js.soy +14 -0
  15. data/test/dummy/app/assets/javascripts/my-closure/start.js +25 -0
  16. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  17. data/test/dummy/app/controllers/application_controller.rb +7 -0
  18. data/test/dummy/app/helpers/application_helper.rb +2 -0
  19. data/test/dummy/app/views/application/index.html.erb +0 -0
  20. data/test/dummy/app/views/layouts/application.html.erb +18 -0
  21. data/test/dummy/config.ru +4 -0
  22. data/test/dummy/config/application.rb +51 -0
  23. data/test/dummy/config/boot.rb +10 -0
  24. data/test/dummy/config/environment.rb +5 -0
  25. data/test/dummy/config/environments/development.rb +30 -0
  26. data/test/dummy/config/environments/production.rb +60 -0
  27. data/test/dummy/config/environments/test.rb +39 -0
  28. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  29. data/test/dummy/config/initializers/inflections.rb +10 -0
  30. data/test/dummy/config/initializers/mime_types.rb +5 -0
  31. data/test/dummy/config/initializers/secret_token.rb +7 -0
  32. data/test/dummy/config/initializers/session_store.rb +8 -0
  33. data/test/dummy/config/initializers/wrap_parameters.rb +10 -0
  34. data/test/dummy/config/initializers/yellow_brick_road.rb +2 -0
  35. data/test/dummy/config/locales/en.yml +5 -0
  36. data/test/dummy/config/routes.rb +58 -0
  37. data/test/dummy/log/development.log +13924 -0
  38. data/test/dummy/log/test.log +0 -0
  39. data/test/dummy/public/404.html +26 -0
  40. data/test/dummy/public/422.html +26 -0
  41. data/test/dummy/public/500.html +26 -0
  42. data/test/dummy/public/favicon.ico +0 -0
  43. data/test/dummy/script/rails +6 -0
  44. data/test/dummy/tmp/cache/assets/BE0/120/sprockets%2F751842b8c6750008c7310d182600d173 +142 -0
  45. data/test/dummy/tmp/cache/assets/C19/950/sprockets%2F142437f1d8d9424007b4a882a5429333 +1372 -0
  46. data/test/dummy/tmp/cache/assets/C4B/D00/sprockets%2F400f22c081529179ce3d079457de3009 +806 -0
  47. data/test/dummy/tmp/cache/assets/C5A/EE0/sprockets%2Fb711429ed948c503b718d077037780f8 +0 -0
  48. data/test/dummy/tmp/cache/assets/C5B/A80/sprockets%2F508569b474262724c61a461f7777dab7 +1118 -0
  49. data/test/dummy/tmp/cache/assets/C6C/660/sprockets%2F2c298b3b02232a21527680685a3efc30 +9289 -0
  50. data/test/dummy/tmp/cache/assets/C72/8A0/sprockets%2F167b265129e30d87d253c406db305c60 +293 -0
  51. data/test/dummy/tmp/cache/assets/C7E/9F0/sprockets%2F89862076204c62c4593ac20de32da909 +9 -0
  52. data/test/dummy/tmp/cache/assets/C8B/5F0/sprockets%2Fc6a4470b5c21e285e829a99365839b24 +0 -0
  53. data/test/dummy/tmp/cache/assets/C92/D20/sprockets%2F2e618f7805f445889aec94885a500f03 +457 -0
  54. data/test/dummy/tmp/cache/assets/C98/FD0/sprockets%2Fb11442af041f96e87a43a1dc11231745 +283 -0
  55. data/test/dummy/tmp/cache/assets/CA3/520/sprockets%2F5379d7143c6c52b11b88dc0ab5436133 +277 -0
  56. data/test/dummy/tmp/cache/assets/CA5/450/sprockets%2F6bb727c9312a749134ad67323a317f0d +73 -0
  57. data/test/dummy/tmp/cache/assets/CA5/4F0/sprockets%2Feeb7de7771527700af194c0441d29101 +709 -0
  58. data/test/dummy/tmp/cache/assets/CA6/E90/sprockets%2F611f68180f43c4181f06ae5c5f8201e2 +1546 -0
  59. data/test/dummy/tmp/cache/assets/CA7/310/sprockets%2F45664cf816315200b574e029fde6f10a +0 -0
  60. data/test/dummy/tmp/cache/assets/CA9/9D0/sprockets%2F2672e32464cf7267c4ba3d028f54b153 +224 -0
  61. data/test/dummy/tmp/cache/assets/CAB/5A0/sprockets%2F7f50e0289f150c8636ac9253129bc13c +2556 -0
  62. data/test/dummy/tmp/cache/assets/CB5/7E0/sprockets%2F42ff6672683b2029233a800e7539eeee +474 -0
  63. data/test/dummy/tmp/cache/assets/CB6/DC0/sprockets%2F2f9882155bb2d4d3ab5d708951857c60 +494 -0
  64. data/test/dummy/tmp/cache/assets/CBB/680/sprockets%2F1dc336d96fb52df34b458185559922b5 +1018 -0
  65. data/test/dummy/tmp/cache/assets/CBC/640/sprockets%2F67d2e0d9e5129d237e575d2780c64b47 +1260 -0
  66. data/test/dummy/tmp/cache/assets/CBE/550/sprockets%2Fd680cac830e0b3408ba910f0b0421147 +25 -0
  67. data/test/dummy/tmp/cache/assets/CC7/790/sprockets%2F69941f32a12e4f99d4a57f65386d870d +608 -0
  68. data/test/dummy/tmp/cache/assets/CCB/F80/sprockets%2Fa865701ef2ec41155e524772c31a1a2b +1088 -0
  69. data/test/dummy/tmp/cache/assets/CCE/580/sprockets%2F879411ed27ed1c557d57853d8f579b56 +0 -0
  70. data/test/dummy/tmp/cache/assets/CD0/070/sprockets%2F6748fe8481965f260d9c56b7f9f508a2 +1530 -0
  71. data/test/dummy/tmp/cache/assets/CD4/750/sprockets%2Faf3505141ecb3169ce41ce519d136924 +0 -0
  72. data/test/dummy/tmp/cache/assets/CD6/A90/sprockets%2F3f55ac75b9fb8426312116bcb940a580 +2539 -0
  73. data/test/dummy/tmp/cache/assets/CD9/6C0/sprockets%2F5e2458bc52da90ba349a66035e3b6752 +0 -0
  74. data/test/dummy/tmp/cache/assets/CD9/F50/sprockets%2F9008bf696500cfae1d61f045f209181e +256 -0
  75. data/test/dummy/tmp/cache/assets/CDB/B40/sprockets%2F53529a22c994570a0df4742c0bfe61f4 +0 -0
  76. data/test/dummy/tmp/cache/assets/CDC/D10/sprockets%2F1e775b4ff06b4401c07503ce95a839b5 +75 -0
  77. data/test/dummy/tmp/cache/assets/CDE/CD0/sprockets%2F141066798b4acf07053f7e3a6cb4e555 +1613 -0
  78. data/test/dummy/tmp/cache/assets/CE1/760/sprockets%2F245fe11803630fe30d0cf8a869886ab5 +357 -0
  79. data/test/dummy/tmp/cache/assets/CE1/FA0/sprockets%2F863d1650ef066e4a2168bc57c7c0e096 +0 -0
  80. data/test/dummy/tmp/cache/assets/CE2/310/sprockets%2Fd38075d5592ecaf82e43526c03b467c4 +1545 -0
  81. data/test/dummy/tmp/cache/assets/CE2/420/sprockets%2F30f2e8f30477e80cf6416dfe27307c07 +204 -0
  82. data/test/dummy/tmp/cache/assets/CE2/D70/sprockets%2F467c44b63644e0f44dd06a585f36f1a6 +522 -0
  83. data/test/dummy/tmp/cache/assets/CE3/670/sprockets%2Fddd11860b444cd0f9996be0c46762318 +796 -0
  84. data/test/dummy/tmp/cache/assets/CE4/0B0/sprockets%2Ff11535d785c0d34349c64d673bd4b28f +1105 -0
  85. data/test/dummy/tmp/cache/assets/CE4/590/sprockets%2Fd68edcc87a4ae302794093081b45b819 +10 -0
  86. data/test/dummy/tmp/cache/assets/CE4/D60/sprockets%2F61772e4a60b616f74da91b838a2f4f82 +0 -0
  87. data/test/dummy/tmp/cache/assets/CE6/DD0/sprockets%2F2fe073024a2bf26bd98458388b57af37 +1355 -0
  88. data/test/dummy/tmp/cache/assets/CE7/160/sprockets%2Fba1f9939f031b4356ec1869d40fc2747 +1261 -0
  89. data/test/dummy/tmp/cache/assets/CE8/C70/sprockets%2Fc6c9ba3c677b5e2af8520395192c9445 +173 -0
  90. data/test/dummy/tmp/cache/assets/CEA/8B0/sprockets%2Ff77e549cb6d37604105f35d4e67d8c21 +511 -0
  91. data/test/dummy/tmp/cache/assets/CEA/AA0/sprockets%2F5f816982c86d2e6b72b2f5f65c51d070 +1529 -0
  92. data/test/dummy/tmp/cache/assets/CEA/C10/sprockets%2F9dcd541e67c299ab076a44a2183872f8 +0 -0
  93. data/test/dummy/tmp/cache/assets/CF1/5A0/sprockets%2F1a697695edf2bb7b49a2896904218bc7 +115 -0
  94. data/test/dummy/tmp/cache/assets/CF4/480/sprockets%2F5e99c77e93f4a522c84357e62b25e0f7 +43 -0
  95. data/test/dummy/tmp/cache/assets/CF7/460/sprockets%2Fd12ea9733fe3c92456f57f9145569b9c +0 -0
  96. data/test/dummy/tmp/cache/assets/CF7/470/sprockets%2F2897897a166ca3369fecb88f83f211b5 +435 -0
  97. data/test/dummy/tmp/cache/assets/CFA/760/sprockets%2Fa9024adba14091e0635c6874d1db4e22 +0 -0
  98. data/test/dummy/tmp/cache/assets/D01/F30/sprockets%2Fe639a15b6e0cca37d12443b408e1166f +25 -0
  99. data/test/dummy/tmp/cache/assets/D02/9F0/sprockets%2Fb99eae308897fe88cb9414b96824098b +0 -0
  100. data/test/dummy/tmp/cache/assets/D03/330/sprockets%2F1e003cdb3e7dcc9307e84090ad457127 +454 -0
  101. data/test/dummy/tmp/cache/assets/D03/8B0/sprockets%2Ff74632bddf2c0b2018ca7b736309380e +365 -0
  102. data/test/dummy/tmp/cache/assets/D05/0A0/sprockets%2Fe57658220260db13eb5577aef42cb61b +257 -0
  103. data/test/dummy/tmp/cache/assets/D05/920/sprockets%2F909507434dcc270db4853e4c147f0aac +31 -0
  104. data/test/dummy/tmp/cache/assets/D08/510/sprockets%2Fa567be6cb6d7310096f1739b25a5a3f0 +50 -0
  105. data/test/dummy/tmp/cache/assets/D08/9F0/sprockets%2F1d61d2c89ca50957066bacc5b69011f5 +1424 -0
  106. data/test/dummy/tmp/cache/assets/D0A/790/sprockets%2Feb16913e6504c9b0d3be431de39e4751 +300 -0
  107. data/test/dummy/tmp/cache/assets/D0C/C50/sprockets%2Fd6613bee8b40d50459af6b52a7084f34 +796 -0
  108. data/test/dummy/tmp/cache/assets/D0D/030/sprockets%2Fba3f13b4a444679e8bc2549226ec743b +21 -0
  109. data/test/dummy/tmp/cache/assets/D0D/350/sprockets%2F2670bce036d485e15d059c0f1e98f24a +207 -0
  110. data/test/dummy/tmp/cache/assets/D13/270/sprockets%2F497cb163e6317e3fc1565d832f406cfb +348 -0
  111. data/test/dummy/tmp/cache/assets/D13/380/sprockets%2F786d003c9c7fb759dd26c1030c087cf6 +813 -0
  112. data/test/dummy/tmp/cache/assets/D13/7C0/sprockets%2F528d22310a9ab8e6fba08d82844ce795 +0 -0
  113. data/test/dummy/tmp/cache/assets/D15/F60/sprockets%2Fa28394e3f80365b5bc86794dd46daa22 +0 -0
  114. data/test/dummy/tmp/cache/assets/D18/500/sprockets%2Fd22c2d97d1db2154f2f7592906e957ea +1001 -0
  115. data/test/dummy/tmp/cache/assets/D1B/C70/sprockets%2F1c04848b1e1d6e8e33b8581f8c8128ff +223 -0
  116. data/test/dummy/tmp/cache/assets/D1C/600/sprockets%2Fa0601f99147f59ddd6266e6aff077e14 +0 -0
  117. data/test/dummy/tmp/cache/assets/D1E/470/sprockets%2Fb3933e694547b78bf6fb15f44a4623fe +53 -0
  118. data/test/dummy/tmp/cache/assets/D1F/480/sprockets%2F545164168becf42b289efc8708f1db68 +1278 -0
  119. data/test/dummy/tmp/cache/assets/D21/630/sprockets%2F0a14114729c14637f2e8f122acabd1ab +823 -0
  120. data/test/dummy/tmp/cache/assets/D24/A90/sprockets%2F21c8a0d48c51b8585ba03bc112ecd153 +692 -0
  121. data/test/dummy/tmp/cache/assets/D25/D30/sprockets%2F3b937f4c16d2aa0a28fc02a0e922712b +1441 -0
  122. data/test/dummy/tmp/cache/assets/D25/F30/sprockets%2Fe251527c0c018f4b4ad44b2ad7064fb0 +2255 -0
  123. data/test/dummy/tmp/cache/assets/D26/DE0/sprockets%2F761ac1bdb0739cc56fa0c1224b137b09 +0 -0
  124. data/test/dummy/tmp/cache/assets/D2A/C30/sprockets%2F978fe7268754f451c59b9ccb323ffa56 +0 -0
  125. data/test/dummy/tmp/cache/assets/D2B/0F0/sprockets%2Fbf223af03335cfc08a71e549e10c0e27 +2539 -0
  126. data/test/dummy/tmp/cache/assets/D2E/6D0/sprockets%2F9e7fda3affb389313cc50223f01c0324 +0 -0
  127. data/test/dummy/tmp/cache/assets/D2F/110/sprockets%2F3730ffe2ed34c1219d580bd1615ea7b0 +2239 -0
  128. data/test/dummy/tmp/cache/assets/D2F/F10/sprockets%2F9cac242f0bf5ec00079ea3a463e26552 +153 -0
  129. data/test/dummy/tmp/cache/assets/D30/1D0/sprockets%2Fd690a26a0b0ae138c1c48d257a7674bc +589 -0
  130. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  131. data/test/dummy/tmp/cache/assets/D36/940/sprockets%2Fb4ba462ac9f4aac561c36e60367c1378 +572 -0
  132. data/test/dummy/tmp/cache/assets/D37/090/sprockets%2F2f2e71ebbc240014ebf648f0917e854a +798 -0
  133. data/test/dummy/tmp/cache/assets/D3A/440/sprockets%2F6d332243647c841dea36ed822cdfc23e +165 -0
  134. data/test/dummy/tmp/cache/assets/D3B/5A0/sprockets%2F82e05cf8c88ba8cb1c87e50d51372a03 +0 -0
  135. data/test/dummy/tmp/cache/assets/D41/B30/sprockets%2Fba1b93913dd01d83ac9a96df334456f8 +0 -0
  136. data/test/dummy/tmp/cache/assets/D43/D90/sprockets%2F04f3a5926d5a7672456dc7afa73d0c7f +38 -0
  137. data/test/dummy/tmp/cache/assets/D45/1F0/sprockets%2F1bfa855d9c10ff2431a9a548958cc5e4 +83 -0
  138. data/test/dummy/tmp/cache/assets/D45/B10/sprockets%2F643f3d9b216e48df952b7f150a46a7ec +60 -0
  139. data/test/dummy/tmp/cache/assets/D46/040/sprockets%2F199546844e5939721a5afcbcce4ea43a +143 -0
  140. data/test/dummy/tmp/cache/assets/D49/320/sprockets%2Fd8123eb229e34c9f507f7b1876f1c4ee +506 -0
  141. data/test/dummy/tmp/cache/assets/D49/750/sprockets%2Ff41ef1c0832b7294fb15588ff5c783cb +0 -0
  142. data/test/dummy/tmp/cache/assets/D49/930/sprockets%2F1071926698fa55abc71e1b6fd966dfe1 +72 -0
  143. data/test/dummy/tmp/cache/assets/D49/D10/sprockets%2Fb67b8d7cc7579352a91694f9ae10cdb0 +127 -0
  144. data/test/dummy/tmp/cache/assets/D4A/160/sprockets%2Fcbd8988b5e18d153eff6230d72e9046a +516 -0
  145. data/test/dummy/tmp/cache/assets/D4A/2B0/sprockets%2Ffcdf002d38fd938bf7226b46b76706c8 +1101 -0
  146. data/test/dummy/tmp/cache/assets/D4E/2F0/sprockets%2F77cb87ae57f0d8c25cdaa74181a64997 +1441 -0
  147. data/test/dummy/tmp/cache/assets/D4F/060/sprockets%2Fa9e66b39ada7394a29bf44f3a682f665 +511 -0
  148. data/test/dummy/tmp/cache/assets/D50/BD0/sprockets%2F88650dd57ef64075462e6dae757dbe2c +0 -0
  149. data/test/dummy/tmp/cache/assets/D53/CA0/sprockets%2Fa85032e82709a043fbb2ec00e04f2bbd +0 -0
  150. data/test/dummy/tmp/cache/assets/D54/BF0/sprockets%2F91970514ff528e8d2bfd81f1ec83c9c8 +240 -0
  151. data/test/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +10 -0
  152. data/test/dummy/tmp/cache/assets/D56/500/sprockets%2F75ebadd035f1324b194034af92eac3a0 +0 -0
  153. data/test/dummy/tmp/cache/assets/D5A/900/sprockets%2F5729f77d97fdee53b1942cf17f6f05e4 +474 -0
  154. data/test/dummy/tmp/cache/assets/D5A/D50/sprockets%2F81bace3db2c2f1241175ff3c5009d08c +0 -0
  155. data/test/dummy/tmp/cache/assets/D5B/C70/sprockets%2Fe64119a9db7017b7ab3b0da1b6076f0d +44 -0
  156. data/test/dummy/tmp/cache/assets/D5E/4D0/sprockets%2F756f25e4ad861a050cdc41bb8414e4ab +126 -0
  157. data/test/dummy/tmp/cache/assets/D5E/730/sprockets%2Fd30caf70b387c4604326bdda32aeb549 +0 -0
  158. data/test/dummy/tmp/cache/assets/D5E/AA0/sprockets%2F790dd07caaaacb30ceb0174664e90817 +136 -0
  159. data/test/dummy/tmp/cache/assets/D64/D30/sprockets%2Fe4bd8f60a3a446274c3cb2f5d16563ac +590 -0
  160. data/test/dummy/tmp/cache/assets/D66/400/sprockets%2Fecb7401d20daf25605a7afad3a793778 +0 -0
  161. data/test/dummy/tmp/cache/assets/D67/250/sprockets%2F8422eb26855ca9c953a3bf1aeade8004 +0 -0
  162. data/test/dummy/tmp/cache/assets/D69/900/sprockets%2F28ae64f52cb18f77b1a1bd9c51293da4 +0 -0
  163. data/test/dummy/tmp/cache/assets/D6A/870/sprockets%2F1ece6a51b42f9280f4cee9020c94b72e +197 -0
  164. data/test/dummy/tmp/cache/assets/D6B/DD0/sprockets%2F9a0abc735e27fc61dab019788518eba4 +164 -0
  165. data/test/dummy/tmp/cache/assets/D6E/CC0/sprockets%2F8b4fbcec2475e7203b8859baf8e310a3 +0 -0
  166. data/test/dummy/tmp/cache/assets/D72/470/sprockets%2Fbc0c6d850e7c769e83d58eb3e6061b2a +2556 -0
  167. data/test/dummy/tmp/cache/assets/D72/9D0/sprockets%2F9402daf6da6f7eed331a9d78216cb761 +0 -0
  168. data/test/dummy/tmp/cache/assets/D74/070/sprockets%2F91ae68f698a39bd7d0d11150fc46e4cd +418 -0
  169. data/test/dummy/tmp/cache/assets/D74/7F0/sprockets%2F22dad1069ea6a8f29ae757c44e18ec83 +0 -0
  170. data/test/dummy/tmp/cache/assets/D75/3C0/sprockets%2F44e2ae51b97853d8ecda7b264a267c7d +1630 -0
  171. data/test/dummy/tmp/cache/assets/D77/780/sprockets%2Ffa2abdfb0b62867c346f79187b8e42d5 +823 -0
  172. data/test/dummy/tmp/cache/assets/D79/850/sprockets%2F4d540586ed379fd9a70fa0b7ce4f5b27 +306 -0
  173. data/test/dummy/tmp/cache/assets/D7A/B60/sprockets%2F5925c92f48caff053d08853dc69e5bba +0 -0
  174. data/test/dummy/tmp/cache/assets/D81/C90/sprockets%2F19aca5c835efce74878c23e581e2a89e +2239 -0
  175. data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +11228 -0
  176. data/test/dummy/tmp/cache/assets/D8B/B10/sprockets%2Fbb7a2305a8f2832631863bbababb67be +301 -0
  177. data/test/dummy/tmp/cache/assets/D92/3B0/sprockets%2F93dc71f411faf72ec8ef0b5d217b51a0 +505 -0
  178. data/test/dummy/tmp/cache/assets/D92/EE0/sprockets%2Ffd051ea0abf6be6970754aa732e40c8b +289 -0
  179. data/test/dummy/tmp/cache/assets/D93/810/sprockets%2F7dc1ac5e1b83ba5144e34cf156d48a8a +471 -0
  180. data/test/dummy/tmp/cache/assets/D94/020/sprockets%2F35cb4ce22488fb5bdd260508ca47a3fb +239 -0
  181. data/test/dummy/tmp/cache/assets/D94/EC0/sprockets%2F8b900fba18f8e046f5f12e6d1f0ac15b +74 -0
  182. data/test/dummy/tmp/cache/assets/D95/470/sprockets%2F5be5d361a52575c433831b5e8cccbace +9273 -0
  183. data/test/dummy/tmp/cache/assets/D97/9D0/sprockets%2F524a2a94a88c1d392dabcba654e365fc +103 -0
  184. data/test/dummy/tmp/cache/assets/D9D/800/sprockets%2Ff8387220eb4dda9b29a37b5deb9f2a40 +54 -0
  185. data/test/dummy/tmp/cache/assets/D9E/DD0/sprockets%2Fb6b4ffad6485eda046b327a196e8c44a +0 -0
  186. data/test/dummy/tmp/cache/assets/DA1/0A0/sprockets%2F359c94aee6ba2e15fc9666aa4de311c8 +166 -0
  187. data/test/dummy/tmp/cache/assets/DA1/0D0/sprockets%2F798de3c28452e164a7fc1a3a6e8cdb4b +652 -0
  188. data/test/dummy/tmp/cache/assets/DA3/CB0/sprockets%2Fdfad6bb1857a8af91f98ba137c18504e +815 -0
  189. data/test/dummy/tmp/cache/assets/DA4/E10/sprockets%2Fbda7705734ace95f12a7d79df9c14af2 +1354 -0
  190. data/test/dummy/tmp/cache/assets/DA5/E30/sprockets%2F2e6707a119e94a784efbadca18d7e8d1 +129 -0
  191. data/test/dummy/tmp/cache/assets/DA6/4B0/sprockets%2F4f7a708b6aa2d42eb577493dea7cef55 +115 -0
  192. data/test/dummy/tmp/cache/assets/DA8/A10/sprockets%2F0ae5bbb4ca200e74db3b64d72c2be120 +0 -0
  193. data/test/dummy/tmp/cache/assets/DA9/3F0/sprockets%2Fdd0af9cfd65fb7d02fe778c8f6015361 +499 -0
  194. data/test/dummy/tmp/cache/assets/DA9/780/sprockets%2Fe3559a635e8f92dec7727a3db2ae7b4c +813 -0
  195. data/test/dummy/tmp/cache/assets/DAC/0E0/sprockets%2F04cef8243a9ef7321846debc977ea8db +607 -0
  196. data/test/dummy/tmp/cache/assets/DB1/260/sprockets%2Fb879ff7530bf8cc175e0c7e70dc4e79b +0 -0
  197. data/test/dummy/tmp/cache/assets/DB4/4C0/sprockets%2F30a76cbd98dedb56742cd8ecaf858757 +0 -0
  198. data/test/dummy/tmp/cache/assets/DBD/7E0/sprockets%2F236fb1ac5ed9f2e3fe32203acc3a842d +0 -0
  199. data/test/dummy/tmp/cache/assets/DC2/DF0/sprockets%2Fe233bcaba8beff15626c35cb5e0e0936 +845 -0
  200. data/test/dummy/tmp/cache/assets/DC4/600/sprockets%2F59c96aa6c1cbebc61bff6c050a5351d7 +225 -0
  201. data/test/dummy/tmp/cache/assets/DC5/030/sprockets%2Fcb2fe864a0177eec19017c43ce9aa4ad +187 -0
  202. data/test/dummy/tmp/cache/assets/DC8/A60/sprockets%2F9fcb9f5c3f679ce749ee4c3f93869ba6 +74 -0
  203. data/test/dummy/tmp/cache/assets/DCB/D40/sprockets%2Ffd5542bfb7660a8d8cac3a2e46fb01f8 +828 -0
  204. data/test/dummy/tmp/cache/assets/DCC/020/sprockets%2F0c129c5f2784c96fa1dc3da6c19c1efc +128 -0
  205. data/test/dummy/tmp/cache/assets/DCF/520/sprockets%2F975162fb97a3ec7033db5f2fdba4fcd3 +70 -0
  206. data/test/dummy/tmp/cache/assets/DD0/000/sprockets%2F0d5d631cce6f0b078bb29cf98b3d78bb +276 -0
  207. data/test/dummy/tmp/cache/assets/DD0/C90/sprockets%2F84eeca4ef8f5eb29b13f7e1ea3c71324 +591 -0
  208. data/test/dummy/tmp/cache/assets/DD6/710/sprockets%2F9e83f2ebbe3e349efca2de390e15d635 +204 -0
  209. data/test/dummy/tmp/cache/assets/DE1/830/sprockets%2Fd23d3cafef2e2a9055bc103dffc1a023 +208 -0
  210. data/test/dummy/tmp/cache/assets/DEB/470/sprockets%2Fae2de0fcbc2214b71d3f2a875d2bc8c3 +2255 -0
  211. data/test/dummy/tmp/cache/assets/DEE/690/sprockets%2F5d824bcadef29060cc13eed71af4b4d0 +550 -0
  212. data/test/dummy/tmp/cache/assets/DF0/5D0/sprockets%2F25a875eb0a5d4c49bcc3fa39ea0adb26 +567 -0
  213. data/test/dummy/tmp/cache/assets/DF3/E20/sprockets%2Fada770c49a5d6b38d1cc43ed4d51c1fc +0 -0
  214. data/test/dummy/tmp/cache/assets/DF5/C80/sprockets%2F03ad7d7b3a8feba9ed9be82ae2083b20 +340 -0
  215. data/test/dummy/tmp/cache/assets/DF6/560/sprockets%2Fafceb2b55eb108efe4446dfb02b519b8 +0 -0
  216. data/test/dummy/tmp/cache/assets/DFC/030/sprockets%2Fcbdd3679eaba219b4e1ff20677af1c6f +1371 -0
  217. data/test/dummy/tmp/cache/assets/E00/970/sprockets%2F8bc6dde8d05c382dd07cbcec70f54e09 +378 -0
  218. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  219. data/test/dummy/tmp/cache/assets/E12/2F0/sprockets%2F5c45062ecfbe512dcba176ba6ddacc00 +523 -0
  220. data/test/dummy/tmp/cache/assets/E21/5D0/sprockets%2Fd4fe6d611bfb0e63c04de5dbfb128a8a +0 -0
  221. data/test/dummy/tmp/cache/assets/E22/770/sprockets%2F2ccebcabfbb9b59159e4b73b3b30a74d +208 -0
  222. data/test/dummy/tmp/cache/assets/E31/A90/sprockets%2F26b98bbbc15eee9b370c7dcde88d16aa +394 -0
  223. data/test/dummy/tmp/cache/assets/E31/E30/sprockets%2Ffbdafcc4e2f44bb9fc653bcf9625b750 +284 -0
  224. data/test/dummy/tmp/cache/assets/E37/1C0/sprockets%2Fa5eb45fc86dafe2bee4e4fa3f53c4785 +0 -0
  225. data/test/dummy/tmp/cache/assets/E4C/960/sprockets%2F13fd6e4bfdf031acb3dedca8d0f407b4 +1277 -0
  226. data/test/dummy/tmp/cache/assets/E88/330/sprockets%2Fe02d0adb5529ffafcea1b9e5ccf69a5b +669 -0
  227. data/test/dummy/tmp/pids/server.pid +1 -0
  228. data/test/dummy/tmp/simple.js.js +20 -0
  229. data/test/dummy/tmp/soy-1325274421.js +20 -0
  230. data/test/dummy/tmp/soy-1325286267.js +20 -0
  231. data/test/test_helper.rb +10 -0
  232. data/test/yellow-brick-road_test.rb +7 -0
  233. metadata +538 -0
@@ -0,0 +1,197 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1325441615.790071: @value{ I" length:EFiI" digest;
2
+ F"%40fd210fa6624829e6a5ddfbdf867d57I" source;
3
+ FI"// Copyright 2006 The Closure Library Authors. All Rights Reserved.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 (the "License");
6
+ // you may not use this file except in compliance with the License.
7
+ // You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing, software
12
+ // distributed under the License is distributed on an "AS-IS" BASIS,
13
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ // See the License for the specific language governing permissions and
15
+ // limitations under the License.
16
+
17
+ /**
18
+ * @fileoverview
19
+ * DataSource implementation that uses XMLHttpRequest as transport, with
20
+ * response as serialized JS object (not required to be JSON) that can
21
+ * be evaluated and set to a variable.
22
+ *
23
+ * Response can have unexecutable starting/ending text to prevent inclusion
24
+ * using <script src="...">
25
+ *
26
+ */
27
+
28
+
29
+
30
+ goog.provide('goog.ds.JsXmlHttpDataSource');
31
+
32
+ goog.require('goog.Uri');
33
+ goog.require('goog.ds.DataManager');
34
+ goog.require('goog.ds.FastDataNode');
35
+ goog.require('goog.ds.LoadState');
36
+ goog.require('goog.ds.logger');
37
+ goog.require('goog.events');
38
+ goog.require('goog.net.EventType');
39
+ goog.require('goog.net.XhrIo');
40
+
41
+
42
+
43
+ /**
44
+ * Similar to JsonDataSource, with using XMLHttpRequest for transport
45
+ * Currently requires the result be a JS object that can be evaluated and
46
+ * set to a variable and doesn't require strict JSON notation.
47
+ *
48
+ * @param {string || goog.Uri} uri URI for the request.
49
+ * @param {string} name Name of the datasource.
50
+ * @param {string=} opt_startText Text to expect/strip before JS response.
51
+ * @param {string=} opt_endText Text to expect/strip after JS response.
52
+ * @param {boolean=} opt_usePost If true, use POST. Defaults to false (GET).
53
+ *
54
+ * @extends {goog.ds.FastDataNode}
55
+ * @constructor
56
+ */
57
+ goog.ds.JsXmlHttpDataSource = function(uri, name, opt_startText, opt_endText,
58
+ opt_usePost) {
59
+ goog.ds.FastDataNode.call(this, {}, name, null);
60
+ if (uri) {
61
+ this.uri_ = new goog.Uri(uri);
62
+ this.xhr_ = new goog.net.XhrIo();
63
+ this.usePost_ = !!opt_usePost;
64
+
65
+ goog.events.listen(this.xhr_, goog.net.EventType.COMPLETE,
66
+ this.completed_, false, this);
67
+ } else {
68
+ this.uri_ = null;
69
+ }
70
+ this.startText_ = opt_startText;
71
+ this.endText_ = opt_endText;
72
+ };
73
+ goog.inherits(goog.ds.JsXmlHttpDataSource, goog.ds.FastDataNode);
74
+
75
+
76
+ /**
77
+ * Delimiter for start of JSON data in response.
78
+ * null = starts at first character of response
79
+ * @type {string|undefined}
80
+ * @private
81
+ */
82
+ goog.ds.JsXmlHttpDataSource.prototype.startText_;
83
+
84
+
85
+ /**
86
+ * Delimiter for end of JSON data in response.
87
+ * null = ends at last character of response
88
+ * @type {string|undefined}
89
+ * @private
90
+ */
91
+ goog.ds.JsXmlHttpDataSource.prototype.endText_;
92
+
93
+
94
+ /**
95
+ * Gets the state of the backing data for this node
96
+ * @return {goog.ds.LoadState} The state.
97
+ */
98
+ goog.ds.JsXmlHttpDataSource.prototype.getLoadState = function() {
99
+ return this.loadState_;
100
+ };
101
+
102
+
103
+ /**
104
+ * Sets the request data. This can be used if it is required to
105
+ * send a specific body rather than build the body from the query
106
+ * parameters. Only used in POST requests.
107
+ * @param {string} data The data to send in the request body.
108
+ */
109
+ goog.ds.JsXmlHttpDataSource.prototype.setQueryData = function(data) {
110
+ this.queryData_ = data;
111
+ };
112
+
113
+
114
+ /**
115
+ * Load or reload the backing data for this node.
116
+ * Fires the JsonDataSource
117
+ */
118
+ goog.ds.JsXmlHttpDataSource.prototype.load = function() {
119
+ goog.ds.logger.info('Sending JS request for DataSource ' +
120
+ this.getDataName() + ' to ' + this.uri_);
121
+
122
+ if (this.uri_) {
123
+ if (this.usePost_) {
124
+
125
+ var queryData;
126
+ if (!this.queryData_) {
127
+ queryData = this.uri_.getQueryData().toString();
128
+ } else {
129
+ queryData = this.queryData_;
130
+ }
131
+
132
+ var uriNoQuery = this.uri_.clone();
133
+ uriNoQuery.setQueryData(null);
134
+ this.xhr_.send(String(uriNoQuery), 'POST', queryData);
135
+ } else {
136
+ this.xhr_.send(String(this.uri_));
137
+ }
138
+ } else {
139
+ this.loadState_ = goog.ds.LoadState.NOT_LOADED;
140
+ }
141
+ };
142
+
143
+
144
+ /**
145
+ * Called on successful request.
146
+ * @private
147
+ */
148
+ goog.ds.JsXmlHttpDataSource.prototype.success_ = function() {
149
+ goog.ds.DataManager.getInstance().fireDataChange(this.getDataName());
150
+ };
151
+
152
+
153
+ /**
154
+ * Completed callback. Loads data if successful, otherwise sets
155
+ * state to FAILED
156
+ * @param {goog.events.Event} e Event object, Xhr is target.
157
+ * @private
158
+ */
159
+ goog.ds.JsXmlHttpDataSource.prototype.completed_ = function(e) {
160
+ if (this.xhr_.isSuccess()) {
161
+ goog.ds.logger.info('Got data for DataSource ' + this.getDataName());
162
+ var text = this.xhr_.getResponseText();
163
+
164
+ // Look for start and end token and trim text
165
+ if (this.startText_) {
166
+ var startpos = text.indexOf(this.startText_);
167
+ text = text.substring(startpos + this.startText_.length);
168
+ }
169
+ if (this.endText_) {
170
+ var endpos = text.lastIndexOf(this.endText_);
171
+ text = text.substring(0, endpos);
172
+ }
173
+
174
+ // Eval result
175
+ /** @preserveTry */
176
+ try {
177
+ var jsonObj = /** @type {Object} */ (eval('[' + text + '][0]'));
178
+ this.extendWith_(jsonObj);
179
+ this.loadState_ = goog.ds.LoadState.LOADED;
180
+ }
181
+ catch (ex) {
182
+ // Invalid JS
183
+ this.loadState_ = goog.ds.LoadState.FAILED;
184
+ goog.ds.logger.severe('Failed to parse data: ' + ex.message);
185
+ }
186
+
187
+ // Call on a timer to avoid threading issues on IE.
188
+ goog.global.setTimeout(goog.bind(this.success_, this), 0);
189
+ } else {
190
+ goog.ds.logger.info('Data retrieve failed for DataSource ' +
191
+ this.getDataName());
192
+ this.loadState_ = goog.ds.LoadState.FAILED;
193
+ }
194
+ };
195
+ ;
196
+ FI"
197
+ F"%640187bdab7a1e677d52b76481241fb2
@@ -0,0 +1,164 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1325441615.105026: @value{ I" length:EFiuI" digest;
2
+ F"%f14289208dc4b9cd013476e7f1adfa43I" source;
3
+ FI"u// Copyright 2010 The Closure Library Authors. All Rights Reserved.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 (the "License");
6
+ // you may not use this file except in compliance with the License.
7
+ // You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing, software
12
+ // distributed under the License is distributed on an "AS-IS" BASIS,
13
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ // See the License for the specific language governing permissions and
15
+ // limitations under the License.
16
+
17
+ /**
18
+ * @fileoverview A global registry for entry points into a program,
19
+ * so that they can be instrumented. Each module should register their
20
+ * entry points with this registry. Designed to be compiled out
21
+ * if no instrumentation is requested.
22
+ *
23
+ * Entry points may be registered before or after a call to
24
+ * goog.debug.entryPointRegistry.monitorAll. If an entry point is registered
25
+ * later, the existing monitor will instrument the new entry point.
26
+ *
27
+ * @author nicksantos@google.com (Nick Santos)
28
+ */
29
+
30
+
31
+ goog.provide('goog.debug.EntryPointMonitor');
32
+ goog.provide('goog.debug.entryPointRegistry');
33
+
34
+ goog.require('goog.asserts');
35
+
36
+
37
+
38
+ /**
39
+ * @interface
40
+ */
41
+ goog.debug.EntryPointMonitor = function() {};
42
+
43
+
44
+ /**
45
+ * Instruments a function.
46
+ *
47
+ * @param {!Function} fn A function to instrument.
48
+ * @return {!Function} The instrumented function.
49
+ */
50
+ goog.debug.EntryPointMonitor.prototype.wrap;
51
+
52
+
53
+ /**
54
+ * Try to remove an instrumentation wrapper created by this monitor.
55
+ * If the function passed to unwrap is not a wrapper created by this
56
+ * monitor, then we will do nothing.
57
+ *
58
+ * Notice that some wrappers may not be unwrappable. For example, if other
59
+ * monitors have applied their own wrappers, then it will be impossible to
60
+ * unwrap them because their wrappers will have captured our wrapper.
61
+ *
62
+ * So it is important that entry points are unwrapped in the reverse
63
+ * order that they were wrapped.
64
+ *
65
+ * @param {!Function} fn A function to unwrap.
66
+ * @return {!Function} The unwrapped function, or {@code fn} if it was not
67
+ * a wrapped function created by this monitor.
68
+ */
69
+ goog.debug.EntryPointMonitor.prototype.unwrap;
70
+
71
+
72
+ /**
73
+ * An array of entry point callbacks.
74
+ * @type {!Array.<function(!Function)>}
75
+ * @private
76
+ */
77
+ goog.debug.entryPointRegistry.refList_ = [];
78
+
79
+
80
+ /**
81
+ * Monitors that should wrap all the entry points.
82
+ * @type {!Array.<!goog.debug.EntryPointMonitor>}
83
+ * @private
84
+ */
85
+ goog.debug.entryPointRegistry.monitors_ = [];
86
+
87
+
88
+ /**
89
+ * Whether goog.debug.entryPointRegistry.monitorAll has ever been called.
90
+ * Checking this allows the compiler to optimize out the registrations.
91
+ * @type {boolean}
92
+ * @private
93
+ */
94
+ goog.debug.entryPointRegistry.monitorsMayExist_ = false;
95
+
96
+
97
+ /**
98
+ * Register an entry point with this module.
99
+ *
100
+ * The entry point will be instrumented when a monitor is passed to
101
+ * goog.debug.entryPointRegistry.monitorAll. If this has already occurred, the
102
+ * entry point is instrumented immediately.
103
+ *
104
+ * @param {function(!Function)} callback A callback function which is called
105
+ * with a transforming function to instrument the entry point. The callback
106
+ * is responsible for wrapping the relevant entry point with the
107
+ * transforming function.
108
+ */
109
+ goog.debug.entryPointRegistry.register = function(callback) {
110
+ // Don't use push(), so that this can be compiled out.
111
+ goog.debug.entryPointRegistry.refList_[
112
+ goog.debug.entryPointRegistry.refList_.length] = callback;
113
+ // If no one calls monitorAll, this can be compiled out.
114
+ if (goog.debug.entryPointRegistry.monitorsMayExist_) {
115
+ var monitors = goog.debug.entryPointRegistry.monitors_;
116
+ for (var i = 0; i < monitors.length; i++) {
117
+ callback(goog.bind(monitors[i].wrap, monitors[i]));
118
+ }
119
+ }
120
+ };
121
+
122
+
123
+ /**
124
+ * Configures a monitor to wrap all entry points.
125
+ *
126
+ * Entry points that have already been registered are immediately wrapped by
127
+ * the monitor. When an entry point is registered in the future, it will also
128
+ * be wrapped by the monitor when it is registered.
129
+ *
130
+ * @param {!goog.debug.EntryPointMonitor} monitor An entry point monitor.
131
+ */
132
+ goog.debug.entryPointRegistry.monitorAll = function(monitor) {
133
+ goog.debug.entryPointRegistry.monitorsMayExist_ = true;
134
+ var transformer = goog.bind(monitor.wrap, monitor);
135
+ for (var i = 0; i < goog.debug.entryPointRegistry.refList_.length; i++) {
136
+ goog.debug.entryPointRegistry.refList_[i](transformer);
137
+ }
138
+ goog.debug.entryPointRegistry.monitors_.push(monitor);
139
+ };
140
+
141
+
142
+ /**
143
+ * Try to unmonitor all the entry points that have already been registered. If
144
+ * an entry point is registered in the future, it will not be wrapped by the
145
+ * monitor when it is registered. Note that this may fail if the entry points
146
+ * have additional wrapping.
147
+ *
148
+ * @param {!goog.debug.EntryPointMonitor} monitor The last monitor to wrap
149
+ * the entry points.
150
+ * @throws {Error} If the monitor is not the most recently configured monitor.
151
+ */
152
+ goog.debug.entryPointRegistry.unmonitorAllIfPossible = function(monitor) {
153
+ var monitors = goog.debug.entryPointRegistry.monitors_;
154
+ goog.asserts.assert(monitor == monitors[monitors.length - 1],
155
+ 'Only the most recent monitor can be unwrapped.');
156
+ var transformer = goog.bind(monitor.unwrap, monitor);
157
+ for (var i = 0; i < goog.debug.entryPointRegistry.refList_.length; i++) {
158
+ goog.debug.entryPointRegistry.refList_[i](transformer);
159
+ }
160
+ monitors.length--;
161
+ };
162
+ ;
163
+ FI"
164
+ F"%fe8752c121ced4ed2c97fff0cbf67134
@@ -0,0 +1,2556 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1325458072.999202: @value{I"
2
+ class:EFI"BundledAsset;
3
+ FI"id;
4
+ F"%b1e7a396ba0ab89f2859bcdc0af66f56I"logical_path;
5
+ FI"closure/goog/dom/dom.js;
6
+ TI"
7
+ F"b/Volumes/Development/dev-web/yellow-brick-road/vendor/closure-library/closure/goog/dom/dom.jsI"content_type;
8
+ FI"application/javascript;
9
+ FI"
10
+ mtime;
11
+ FI"2011-12-30T02:16:24+00:00;
12
+ FI" body;
13
+ FI"�C// Copyright 2006 The Closure Library Authors. All Rights Reserved.
14
+ //
15
+ // Licensed under the Apache License, Version 2.0 (the "License");
16
+ // you may not use this file except in compliance with the License.
17
+ // You may obtain a copy of the License at
18
+ //
19
+ // http://www.apache.org/licenses/LICENSE-2.0
20
+ //
21
+ // Unless required by applicable law or agreed to in writing, software
22
+ // distributed under the License is distributed on an "AS-IS" BASIS,
23
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
+ // See the License for the specific language governing permissions and
25
+ // limitations under the License.
26
+
27
+ /**
28
+ * @fileoverview Utilities for manipulating the browser's Document Object Model
29
+ * Inspiration taken *heavily* from mochikit (http://mochikit.com/).
30
+ *
31
+ * You can use {@link goog.dom.DomHelper} to create new dom helpers that refer
32
+ * to a different document object. This is useful if you are working with
33
+ * frames or multiple windows.
34
+ *
35
+ */
36
+
37
+
38
+ // TODO(arv): Rename/refactor getTextContent and getRawTextContent. The problem
39
+ // is that getTextContent should mimic the DOM3 textContent. We should add a
40
+ // getInnerText (or getText) which tries to return the visible text, innerText.
41
+
42
+
43
+ goog.provide('goog.dom');
44
+ goog.provide('goog.dom.DomHelper');
45
+ goog.provide('goog.dom.NodeType');
46
+
47
+ goog.require('goog.array');
48
+ goog.require('goog.dom.BrowserFeature');
49
+ goog.require('goog.dom.TagName');
50
+ goog.require('goog.dom.classes');
51
+ goog.require('goog.math.Coordinate');
52
+ goog.require('goog.math.Size');
53
+ goog.require('goog.object');
54
+ goog.require('goog.string');
55
+ goog.require('goog.userAgent');
56
+
57
+
58
+ /**
59
+ * @define {boolean} Whether we know at compile time that the browser is in
60
+ * quirks mode.
61
+ */
62
+ goog.dom.ASSUME_QUIRKS_MODE = false;
63
+
64
+
65
+ /**
66
+ * @define {boolean} Whether we know at compile time that the browser is in
67
+ * standards compliance mode.
68
+ */
69
+ goog.dom.ASSUME_STANDARDS_MODE = false;
70
+
71
+
72
+ /**
73
+ * Whether we know the compatibility mode at compile time.
74
+ * @type {boolean}
75
+ * @private
76
+ */
77
+ goog.dom.COMPAT_MODE_KNOWN_ =
78
+ goog.dom.ASSUME_QUIRKS_MODE || goog.dom.ASSUME_STANDARDS_MODE;
79
+
80
+
81
+ /**
82
+ * Enumeration for DOM node types (for reference)
83
+ * @enum {number}
84
+ */
85
+ goog.dom.NodeType = {
86
+ ELEMENT: 1,
87
+ ATTRIBUTE: 2,
88
+ TEXT: 3,
89
+ CDATA_SECTION: 4,
90
+ ENTITY_REFERENCE: 5,
91
+ ENTITY: 6,
92
+ PROCESSING_INSTRUCTION: 7,
93
+ COMMENT: 8,
94
+ DOCUMENT: 9,
95
+ DOCUMENT_TYPE: 10,
96
+ DOCUMENT_FRAGMENT: 11,
97
+ NOTATION: 12
98
+ };
99
+
100
+
101
+ /**
102
+ * Gets the DomHelper object for the document where the element resides.
103
+ * @param {Node|Window=} opt_element If present, gets the DomHelper for this
104
+ * element.
105
+ * @return {!goog.dom.DomHelper} The DomHelper.
106
+ */
107
+ goog.dom.getDomHelper = function(opt_element) {
108
+ return opt_element ?
109
+ new goog.dom.DomHelper(goog.dom.getOwnerDocument(opt_element)) :
110
+ (goog.dom.defaultDomHelper_ ||
111
+ (goog.dom.defaultDomHelper_ = new goog.dom.DomHelper()));
112
+ };
113
+
114
+
115
+ /**
116
+ * Cached default DOM helper.
117
+ * @type {goog.dom.DomHelper}
118
+ * @private
119
+ */
120
+ goog.dom.defaultDomHelper_;
121
+
122
+
123
+ /**
124
+ * Gets the document object being used by the dom library.
125
+ * @return {!Document} Document object.
126
+ */
127
+ goog.dom.getDocument = function() {
128
+ return document;
129
+ };
130
+
131
+
132
+ /**
133
+ * Alias for getElementById. If a DOM node is passed in then we just return
134
+ * that.
135
+ * @param {string|Element} element Element ID or a DOM node.
136
+ * @return {Element} The element with the given ID, or the node passed in.
137
+ */
138
+ goog.dom.getElement = function(element) {
139
+ return goog.isString(element) ?
140
+ document.getElementById(element) : element;
141
+ };
142
+
143
+
144
+ /**
145
+ * Alias for getElement.
146
+ * @param {string|Element} element Element ID or a DOM node.
147
+ * @return {Element} The element with the given ID, or the node passed in.
148
+ * @deprecated Use {@link goog.dom.getElement} instead.
149
+ */
150
+ goog.dom.$ = goog.dom.getElement;
151
+
152
+
153
+ /**
154
+ * Looks up elements by both tag and class name, using browser native functions
155
+ * ({@code querySelectorAll}, {@code getElementsByTagName} or
156
+ * {@code getElementsByClassName}) where possible. This function
157
+ * is a useful, if limited, way of collecting a list of DOM elements
158
+ * with certain characteristics. {@code goog.dom.query} offers a
159
+ * more powerful and general solution which allows matching on CSS3
160
+ * selector expressions, but at increased cost in code size. If all you
161
+ * need is particular tags belonging to a single class, this function
162
+ * is fast and sleek.
163
+ *
164
+ * @see {goog.dom.query}
165
+ *
166
+ * @param {?string=} opt_tag Element tag name.
167
+ * @param {?string=} opt_class Optional class name.
168
+ * @param {Document|Element=} opt_el Optional element to look in.
169
+ * @return { {length: number} } Array-like list of elements (only a length
170
+ * property and numerical indices are guaranteed to exist).
171
+ */
172
+ goog.dom.getElementsByTagNameAndClass = function(opt_tag, opt_class, opt_el) {
173
+ return goog.dom.getElementsByTagNameAndClass_(document, opt_tag, opt_class,
174
+ opt_el);
175
+ };
176
+
177
+
178
+ /**
179
+ * Returns an array of all the elements with the provided className.
180
+ * @see {goog.dom.query}
181
+ * @param {string} className the name of the class to look for.
182
+ * @param {Document|Element=} opt_el Optional element to look in.
183
+ * @return { {length: number} } The items found with the class name provided.
184
+ */
185
+ goog.dom.getElementsByClass = function(className, opt_el) {
186
+ var parent = opt_el || document;
187
+ if (goog.dom.canUseQuerySelector_(parent)) {
188
+ return parent.querySelectorAll('.' + className);
189
+ } else if (parent.getElementsByClassName) {
190
+ return parent.getElementsByClassName(className);
191
+ }
192
+ return goog.dom.getElementsByTagNameAndClass_(
193
+ document, '*', className, opt_el);
194
+ };
195
+
196
+
197
+ /**
198
+ * Returns the first element with the provided className.
199
+ * @see {goog.dom.query}
200
+ * @param {string} className the name of the class to look for.
201
+ * @param {Element|Document=} opt_el Optional element to look in.
202
+ * @return {Element} The first item with the class name provided.
203
+ */
204
+ goog.dom.getElementByClass = function(className, opt_el) {
205
+ var parent = opt_el || document;
206
+ var retVal = null;
207
+ if (goog.dom.canUseQuerySelector_(parent)) {
208
+ retVal = parent.querySelector('.' + className);
209
+ } else {
210
+ retVal = goog.dom.getElementsByClass(className, opt_el)[0];
211
+ }
212
+ return retVal || null;
213
+ };
214
+
215
+
216
+ /**
217
+ * Prefer the standardized (http://www.w3.org/TR/selectors-api/), native and
218
+ * fast W3C Selectors API. However, the version of WebKit that shipped with
219
+ * Safari 3.1 and Chrome has a bug where it will not correctly match mixed-
220
+ * case class name selectors in quirks mode.
221
+ * @param {!Element|Document} parent The parent document object.
222
+ * @return {boolean} whether or not we can use parent.querySelector* APIs.
223
+ * @private
224
+ */
225
+ goog.dom.canUseQuerySelector_ = function(parent) {
226
+ return parent.querySelectorAll &&
227
+ parent.querySelector &&
228
+ (!goog.userAgent.WEBKIT || goog.dom.isCss1CompatMode_(document) ||
229
+ goog.userAgent.isVersion('528'));
230
+ };
231
+
232
+
233
+ /**
234
+ * Helper for {@code getElementsByTagNameAndClass}.
235
+ * @param {!Document} doc The document to get the elements in.
236
+ * @param {?string=} opt_tag Element tag name.
237
+ * @param {?string=} opt_class Optional class name.
238
+ * @param {Document|Element=} opt_el Optional element to look in.
239
+ * @return { {length: number} } Array-like list of elements (only a length
240
+ * property and numerical indices are guaranteed to exist).
241
+ * @private
242
+ */
243
+ goog.dom.getElementsByTagNameAndClass_ = function(doc, opt_tag, opt_class,
244
+ opt_el) {
245
+ var parent = opt_el || doc;
246
+ var tagName = (opt_tag && opt_tag != '*') ? opt_tag.toUpperCase() : '';
247
+
248
+ if (goog.dom.canUseQuerySelector_(parent) &&
249
+ (tagName || opt_class)) {
250
+ var query = tagName + (opt_class ? '.' + opt_class : '');
251
+ return parent.querySelectorAll(query);
252
+ }
253
+
254
+ // Use the native getElementsByClassName if available, under the assumption
255
+ // that even when the tag name is specified, there will be fewer elements to
256
+ // filter through when going by class than by tag name
257
+ if (opt_class && parent.getElementsByClassName) {
258
+ var els = parent.getElementsByClassName(opt_class);
259
+
260
+ if (tagName) {
261
+ var arrayLike = {};
262
+ var len = 0;
263
+
264
+ // Filter for specific tags if requested.
265
+ for (var i = 0, el; el = els[i]; i++) {
266
+ if (tagName == el.nodeName) {
267
+ arrayLike[len++] = el;
268
+ }
269
+ }
270
+ arrayLike.length = len;
271
+
272
+ return arrayLike;
273
+ } else {
274
+ return els;
275
+ }
276
+ }
277
+
278
+ var els = parent.getElementsByTagName(tagName || '*');
279
+
280
+ if (opt_class) {
281
+ var arrayLike = {};
282
+ var len = 0;
283
+ for (var i = 0, el; el = els[i]; i++) {
284
+ var className = el.className;
285
+ // Check if className has a split function since SVG className does not.
286
+ if (typeof className.split == 'function' &&
287
+ goog.array.contains(className.split(/\s+/), opt_class)) {
288
+ arrayLike[len++] = el;
289
+ }
290
+ }
291
+ arrayLike.length = len;
292
+ return arrayLike;
293
+ } else {
294
+ return els;
295
+ }
296
+ };
297
+
298
+
299
+ /**
300
+ * Alias for {@code getElementsByTagNameAndClass}.
301
+ * @param {?string=} opt_tag Element tag name.
302
+ * @param {?string=} opt_class Optional class name.
303
+ * @param {Element=} opt_el Optional element to look in.
304
+ * @return { {length: number} } Array-like list of elements (only a length
305
+ * property and numerical indices are guaranteed to exist).
306
+ * @deprecated Use {@link goog.dom.getElementsByTagNameAndClass} instead.
307
+ */
308
+ goog.dom.$$ = goog.dom.getElementsByTagNameAndClass;
309
+
310
+
311
+ /**
312
+ * Sets multiple properties on a node.
313
+ * @param {Element} element DOM node to set properties on.
314
+ * @param {Object} properties Hash of property:value pairs.
315
+ */
316
+ goog.dom.setProperties = function(element, properties) {
317
+ goog.object.forEach(properties, function(val, key) {
318
+ if (key == 'style') {
319
+ element.style.cssText = val;
320
+ } else if (key == 'class') {
321
+ element.className = val;
322
+ } else if (key == 'for') {
323
+ element.htmlFor = val;
324
+ } else if (key in goog.dom.DIRECT_ATTRIBUTE_MAP_) {
325
+ element.setAttribute(goog.dom.DIRECT_ATTRIBUTE_MAP_[key], val);
326
+ } else if (goog.string.startsWith(key, 'aria-')) {
327
+ element.setAttribute(key, val);
328
+ } else {
329
+ element[key] = val;
330
+ }
331
+ });
332
+ };
333
+
334
+
335
+ /**
336
+ * Map of attributes that should be set using
337
+ * element.setAttribute(key, val) instead of element[key] = val. Used
338
+ * by goog.dom.setProperties.
339
+ *
340
+ * @type {Object}
341
+ * @private
342
+ */
343
+ goog.dom.DIRECT_ATTRIBUTE_MAP_ = {
344
+ 'cellpadding': 'cellPadding',
345
+ 'cellspacing': 'cellSpacing',
346
+ 'colspan': 'colSpan',
347
+ 'rowspan': 'rowSpan',
348
+ 'valign': 'vAlign',
349
+ 'height': 'height',
350
+ 'width': 'width',
351
+ 'usemap': 'useMap',
352
+ 'frameborder': 'frameBorder',
353
+ 'maxlength': 'maxLength',
354
+ 'type': 'type'
355
+ };
356
+
357
+
358
+ /**
359
+ * Gets the dimensions of the viewport.
360
+ *
361
+ * Gecko Standards mode:
362
+ * docEl.clientWidth Width of viewport excluding scrollbar.
363
+ * win.innerWidth Width of viewport including scrollbar.
364
+ * body.clientWidth Width of body element.
365
+ *
366
+ * docEl.clientHeight Height of viewport excluding scrollbar.
367
+ * win.innerHeight Height of viewport including scrollbar.
368
+ * body.clientHeight Height of document.
369
+ *
370
+ * Gecko Backwards compatible mode:
371
+ * docEl.clientWidth Width of viewport excluding scrollbar.
372
+ * win.innerWidth Width of viewport including scrollbar.
373
+ * body.clientWidth Width of viewport excluding scrollbar.
374
+ *
375
+ * docEl.clientHeight Height of document.
376
+ * win.innerHeight Height of viewport including scrollbar.
377
+ * body.clientHeight Height of viewport excluding scrollbar.
378
+ *
379
+ * IE6/7 Standards mode:
380
+ * docEl.clientWidth Width of viewport excluding scrollbar.
381
+ * win.innerWidth Undefined.
382
+ * body.clientWidth Width of body element.
383
+ *
384
+ * docEl.clientHeight Height of viewport excluding scrollbar.
385
+ * win.innerHeight Undefined.
386
+ * body.clientHeight Height of document element.
387
+ *
388
+ * IE5 + IE6/7 Backwards compatible mode:
389
+ * docEl.clientWidth 0.
390
+ * win.innerWidth Undefined.
391
+ * body.clientWidth Width of viewport excluding scrollbar.
392
+ *
393
+ * docEl.clientHeight 0.
394
+ * win.innerHeight Undefined.
395
+ * body.clientHeight Height of viewport excluding scrollbar.
396
+ *
397
+ * Opera 9 Standards and backwards compatible mode:
398
+ * docEl.clientWidth Width of viewport excluding scrollbar.
399
+ * win.innerWidth Width of viewport including scrollbar.
400
+ * body.clientWidth Width of viewport excluding scrollbar.
401
+ *
402
+ * docEl.clientHeight Height of document.
403
+ * win.innerHeight Height of viewport including scrollbar.
404
+ * body.clientHeight Height of viewport excluding scrollbar.
405
+ *
406
+ * WebKit:
407
+ * Safari 2
408
+ * docEl.clientHeight Same as scrollHeight.
409
+ * docEl.clientWidth Same as innerWidth.
410
+ * win.innerWidth Width of viewport excluding scrollbar.
411
+ * win.innerHeight Height of the viewport including scrollbar.
412
+ * frame.innerHeight Height of the viewport exluding scrollbar.
413
+ *
414
+ * Safari 3 (tested in 522)
415
+ *
416
+ * docEl.clientWidth Width of viewport excluding scrollbar.
417
+ * docEl.clientHeight Height of viewport excluding scrollbar in strict mode.
418
+ * body.clientHeight Height of viewport excluding scrollbar in quirks mode.
419
+ *
420
+ * @param {Window=} opt_window Optional window element to test.
421
+ * @return {!goog.math.Size} Object with values 'width' and 'height'.
422
+ */
423
+ goog.dom.getViewportSize = function(opt_window) {
424
+ // TODO(arv): This should not take an argument
425
+ return goog.dom.getViewportSize_(opt_window || window);
426
+ };
427
+
428
+
429
+ /**
430
+ * Helper for {@code getViewportSize}.
431
+ * @param {Window} win The window to get the view port size for.
432
+ * @return {!goog.math.Size} Object with values 'width' and 'height'.
433
+ * @private
434
+ */
435
+ goog.dom.getViewportSize_ = function(win) {
436
+ var doc = win.document;
437
+
438
+ if (goog.userAgent.WEBKIT && !goog.userAgent.isVersion('500') &&
439
+ !goog.userAgent.MOBILE) {
440
+ // TODO(user): Sometimes we get something that isn't a valid window
441
+ // object. In this case we just revert to the current window. We need to
442
+ // figure out when this happens and find a real fix for it.
443
+ // See the comments on goog.dom.getWindow.
444
+ if (typeof win.innerHeight == 'undefined') {
445
+ win = window;
446
+ }
447
+ var innerHeight = win.innerHeight;
448
+ var scrollHeight = win.document.documentElement.scrollHeight;
449
+
450
+ if (win == win.top) {
451
+ if (scrollHeight < innerHeight) {
452
+ innerHeight -= 15; // Scrollbars are 15px wide on Mac
453
+ }
454
+ }
455
+ return new goog.math.Size(win.innerWidth, innerHeight);
456
+ }
457
+
458
+ var el = goog.dom.isCss1CompatMode_(doc) ? doc.documentElement : doc.body;
459
+
460
+ return new goog.math.Size(el.clientWidth, el.clientHeight);
461
+ };
462
+
463
+
464
+ /**
465
+ * Calculates the height of the document.
466
+ *
467
+ * @return {number} The height of the current document.
468
+ */
469
+ goog.dom.getDocumentHeight = function() {
470
+ return goog.dom.getDocumentHeight_(window);
471
+ };
472
+
473
+
474
+ /**
475
+ * Calculates the height of the document of the given window.
476
+ *
477
+ * Function code copied from the opensocial gadget api:
478
+ * gadgets.window.adjustHeight(opt_height)
479
+ *
480
+ * @private
481
+ * @param {Window} win The window whose document height to retrieve.
482
+ * @return {number} The height of the document of the given window.
483
+ */
484
+ goog.dom.getDocumentHeight_ = function(win) {
485
+ // NOTE(eae): This method will return the window size rather than the document
486
+ // size in webkit quirks mode.
487
+ var doc = win.document;
488
+ var height = 0;
489
+
490
+ if (doc) {
491
+ // Calculating inner content height is hard and different between
492
+ // browsers rendering in Strict vs. Quirks mode. We use a combination of
493
+ // three properties within document.body and document.documentElement:
494
+ // - scrollHeight
495
+ // - offsetHeight
496
+ // - clientHeight
497
+ // These values differ significantly between browsers and rendering modes.
498
+ // But there are patterns. It just takes a lot of time and persistence
499
+ // to figure out.
500
+
501
+ // Get the height of the viewport
502
+ var vh = goog.dom.getViewportSize_(win).height;
503
+ var body = doc.body;
504
+ var docEl = doc.documentElement;
505
+ if (goog.dom.isCss1CompatMode_(doc) && docEl.scrollHeight) {
506
+ // In Strict mode:
507
+ // The inner content height is contained in either:
508
+ // document.documentElement.scrollHeight
509
+ // document.documentElement.offsetHeight
510
+ // Based on studying the values output by different browsers,
511
+ // use the value that's NOT equal to the viewport height found above.
512
+ height = docEl.scrollHeight != vh ?
513
+ docEl.scrollHeight : docEl.offsetHeight;
514
+ } else {
515
+ // In Quirks mode:
516
+ // documentElement.clientHeight is equal to documentElement.offsetHeight
517
+ // except in IE. In most browsers, document.documentElement can be used
518
+ // to calculate the inner content height.
519
+ // However, in other browsers (e.g. IE), document.body must be used
520
+ // instead. How do we know which one to use?
521
+ // If document.documentElement.clientHeight does NOT equal
522
+ // document.documentElement.offsetHeight, then use document.body.
523
+ var sh = docEl.scrollHeight;
524
+ var oh = docEl.offsetHeight;
525
+ if (docEl.clientHeight != oh) {
526
+ sh = body.scrollHeight;
527
+ oh = body.offsetHeight;
528
+ }
529
+
530
+ // Detect whether the inner content height is bigger or smaller
531
+ // than the bounding box (viewport). If bigger, take the larger
532
+ // value. If smaller, take the smaller value.
533
+ if (sh > vh) {
534
+ // Content is larger
535
+ height = sh > oh ? sh : oh;
536
+ } else {
537
+ // Content is smaller
538
+ height = sh < oh ? sh : oh;
539
+ }
540
+ }
541
+ }
542
+
543
+ return height;
544
+ };
545
+
546
+
547
+ /**
548
+ * Gets the page scroll distance as a coordinate object.
549
+ *
550
+ * @param {Window=} opt_window Optional window element to test.
551
+ * @return {!goog.math.Coordinate} Object with values 'x' and 'y'.
552
+ * @deprecated Use {@link goog.dom.getDocumentScroll} instead.
553
+ */
554
+ goog.dom.getPageScroll = function(opt_window) {
555
+ var win = opt_window || goog.global || window;
556
+ return goog.dom.getDomHelper(win.document).getDocumentScroll();
557
+ };
558
+
559
+
560
+ /**
561
+ * Gets the document scroll distance as a coordinate object.
562
+ *
563
+ * @return {!goog.math.Coordinate} Object with values 'x' and 'y'.
564
+ */
565
+ goog.dom.getDocumentScroll = function() {
566
+ return goog.dom.getDocumentScroll_(document);
567
+ };
568
+
569
+
570
+ /**
571
+ * Helper for {@code getDocumentScroll}.
572
+ *
573
+ * @param {!Document} doc The document to get the scroll for.
574
+ * @return {!goog.math.Coordinate} Object with values 'x' and 'y'.
575
+ * @private
576
+ */
577
+ goog.dom.getDocumentScroll_ = function(doc) {
578
+ var el = goog.dom.getDocumentScrollElement_(doc);
579
+ var win = goog.dom.getWindow_(doc);
580
+ return new goog.math.Coordinate(win.pageXOffset || el.scrollLeft,
581
+ win.pageYOffset || el.scrollTop);
582
+ };
583
+
584
+
585
+ /**
586
+ * Gets the document scroll element.
587
+ * @return {Element} Scrolling element.
588
+ */
589
+ goog.dom.getDocumentScrollElement = function() {
590
+ return goog.dom.getDocumentScrollElement_(document);
591
+ };
592
+
593
+
594
+ /**
595
+ * Helper for {@code getDocumentScrollElement}.
596
+ * @param {!Document} doc The document to get the scroll element for.
597
+ * @return {Element} Scrolling element.
598
+ * @private
599
+ */
600
+ goog.dom.getDocumentScrollElement_ = function(doc) {
601
+ // Safari (2 and 3) needs body.scrollLeft in both quirks mode and strict mode.
602
+ return !goog.userAgent.WEBKIT && goog.dom.isCss1CompatMode_(doc) ?
603
+ doc.documentElement : doc.body;
604
+ };
605
+
606
+
607
+ /**
608
+ * Gets the window object associated with the given document.
609
+ *
610
+ * @param {Document=} opt_doc Document object to get window for.
611
+ * @return {!Window} The window associated with the given document.
612
+ */
613
+ goog.dom.getWindow = function(opt_doc) {
614
+ // TODO(arv): This should not take an argument.
615
+ return opt_doc ? goog.dom.getWindow_(opt_doc) : window;
616
+ };
617
+
618
+
619
+ /**
620
+ * Helper for {@code getWindow}.
621
+ *
622
+ * @param {!Document} doc Document object to get window for.
623
+ * @return {!Window} The window associated with the given document.
624
+ * @private
625
+ */
626
+ goog.dom.getWindow_ = function(doc) {
627
+ return doc.parentWindow || doc.defaultView;
628
+ };
629
+
630
+
631
+ /**
632
+ * Returns a dom node with a set of attributes. This function accepts varargs
633
+ * for subsequent nodes to be added. Subsequent nodes will be added to the
634
+ * first node as childNodes.
635
+ *
636
+ * So:
637
+ * <code>createDom('div', null, createDom('p'), createDom('p'));</code>
638
+ * would return a div with two child paragraphs
639
+ *
640
+ * @param {string} tagName Tag to create.
641
+ * @param {Object|Array.<string>|string=} opt_attributes If object, then a map
642
+ * of name-value pairs for attributes. If a string, then this is the
643
+ * className of the new element. If an array, the elements will be joined
644
+ * together as the className of the new element.
645
+ * @param {...Object|string|Array|NodeList} var_args Further DOM nodes or
646
+ * strings for text nodes. If one of the var_args is an array or NodeList,i
647
+ * its elements will be added as childNodes instead.
648
+ * @return {!Element} Reference to a DOM node.
649
+ */
650
+ goog.dom.createDom = function(tagName, opt_attributes, var_args) {
651
+ return goog.dom.createDom_(document, arguments);
652
+ };
653
+
654
+
655
+ /**
656
+ * Helper for {@code createDom}.
657
+ * @param {!Document} doc The document to create the DOM in.
658
+ * @param {!Arguments} args Argument object passed from the callers. See
659
+ * {@code goog.dom.createDom} for details.
660
+ * @return {!Element} Reference to a DOM node.
661
+ * @private
662
+ */
663
+ goog.dom.createDom_ = function(doc, args) {
664
+ var tagName = args[0];
665
+ var attributes = args[1];
666
+
667
+ // Internet Explorer is dumb: http://msdn.microsoft.com/workshop/author/
668
+ // dhtml/reference/properties/name_2.asp
669
+ // Also does not allow setting of 'type' attribute on 'input' or 'button'.
670
+ if (!goog.dom.BrowserFeature.CAN_ADD_NAME_OR_TYPE_ATTRIBUTES && attributes &&
671
+ (attributes.name || attributes.type)) {
672
+ var tagNameArr = ['<', tagName];
673
+ if (attributes.name) {
674
+ tagNameArr.push(' name="', goog.string.htmlEscape(attributes.name),
675
+ '"');
676
+ }
677
+ if (attributes.type) {
678
+ tagNameArr.push(' type="', goog.string.htmlEscape(attributes.type),
679
+ '"');
680
+
681
+ // Clone attributes map to remove 'type' without mutating the input.
682
+ var clone = {};
683
+ goog.object.extend(clone, attributes);
684
+ attributes = clone;
685
+ delete attributes.type;
686
+ }
687
+ tagNameArr.push('>');
688
+ tagName = tagNameArr.join('');
689
+ }
690
+
691
+ var element = doc.createElement(tagName);
692
+
693
+ if (attributes) {
694
+ if (goog.isString(attributes)) {
695
+ element.className = attributes;
696
+ } else if (goog.isArray(attributes)) {
697
+ goog.dom.classes.add.apply(null, [element].concat(attributes));
698
+ } else {
699
+ goog.dom.setProperties(element, attributes);
700
+ }
701
+ }
702
+
703
+ if (args.length > 2) {
704
+ goog.dom.append_(doc, element, args, 2);
705
+ }
706
+
707
+ return element;
708
+ };
709
+
710
+
711
+ /**
712
+ * Appends a node with text or other nodes.
713
+ * @param {!Document} doc The document to create new nodes in.
714
+ * @param {!Node} parent The node to append nodes to.
715
+ * @param {!Arguments} args The values to add. See {@code goog.dom.append}.
716
+ * @param {number} startIndex The index of the array to start from.
717
+ * @private
718
+ */
719
+ goog.dom.append_ = function(doc, parent, args, startIndex) {
720
+ function childHandler(child) {
721
+ // TODO(user): More coercion, ala MochiKit?
722
+ if (child) {
723
+ parent.appendChild(goog.isString(child) ?
724
+ doc.createTextNode(child) : child);
725
+ }
726
+ }
727
+
728
+ for (var i = startIndex; i < args.length; i++) {
729
+ var arg = args[i];
730
+ // TODO(attila): Fix isArrayLike to return false for a text node.
731
+ if (goog.isArrayLike(arg) && !goog.dom.isNodeLike(arg)) {
732
+ // If the argument is a node list, not a real array, use a clone,
733
+ // because forEach can't be used to mutate a NodeList.
734
+ goog.array.forEach(goog.dom.isNodeList(arg) ?
735
+ goog.array.clone(arg) : arg,
736
+ childHandler);
737
+ } else {
738
+ childHandler(arg);
739
+ }
740
+ }
741
+ };
742
+
743
+
744
+ /**
745
+ * Alias for {@code createDom}.
746
+ * @param {string} tagName Tag to create.
747
+ * @param {string|Object=} opt_attributes If object, then a map of name-value
748
+ * pairs for attributes. If a string, then this is the className of the new
749
+ * element.
750
+ * @param {...Object|string|Array|NodeList} var_args Further DOM nodes or
751
+ * strings for text nodes. If one of the var_args is an array, its
752
+ * children will be added as childNodes instead.
753
+ * @return {!Element} Reference to a DOM node.
754
+ * @deprecated Use {@link goog.dom.createDom} instead.
755
+ */
756
+ goog.dom.$dom = goog.dom.createDom;
757
+
758
+
759
+ /**
760
+ * Creates a new element.
761
+ * @param {string} name Tag name.
762
+ * @return {!Element} The new element.
763
+ */
764
+ goog.dom.createElement = function(name) {
765
+ return document.createElement(name);
766
+ };
767
+
768
+
769
+ /**
770
+ * Creates a new text node.
771
+ * @param {string} content Content.
772
+ * @return {!Text} The new text node.
773
+ */
774
+ goog.dom.createTextNode = function(content) {
775
+ return document.createTextNode(content);
776
+ };
777
+
778
+
779
+ /**
780
+ * Create a table.
781
+ * @param {number} rows The number of rows in the table. Must be >= 1.
782
+ * @param {number} columns The number of columns in the table. Must be >= 1.
783
+ * @param {boolean=} opt_fillWithNbsp If true, fills table entries with nsbps.
784
+ * @return {!Element} The created table.
785
+ */
786
+ goog.dom.createTable = function(rows, columns, opt_fillWithNbsp) {
787
+ return goog.dom.createTable_(document, rows, columns, !!opt_fillWithNbsp);
788
+ };
789
+
790
+
791
+ /**
792
+ * Create a table.
793
+ * @param {!Document} doc Document object to use to create the table.
794
+ * @param {number} rows The number of rows in the table. Must be >= 1.
795
+ * @param {number} columns The number of columns in the table. Must be >= 1.
796
+ * @param {boolean} fillWithNbsp If true, fills table entries with nsbps.
797
+ * @return {!Element} The created table.
798
+ * @private
799
+ */
800
+ goog.dom.createTable_ = function(doc, rows, columns, fillWithNbsp) {
801
+ var rowHtml = ['<tr>'];
802
+ for (var i = 0; i < columns; i++) {
803
+ rowHtml.push(fillWithNbsp ? '<td>&nbsp;</td>' : '<td></td>');
804
+ }
805
+ rowHtml.push('</tr>');
806
+ rowHtml = rowHtml.join('');
807
+ var totalHtml = ['<table>'];
808
+ for (i = 0; i < rows; i++) {
809
+ totalHtml.push(rowHtml);
810
+ }
811
+ totalHtml.push('</table>');
812
+
813
+ var elem = doc.createElement(goog.dom.TagName.DIV);
814
+ elem.innerHTML = totalHtml.join('');
815
+ return /** @type {!Element} */ (elem.removeChild(elem.firstChild));
816
+ };
817
+
818
+
819
+ /**
820
+ * Converts an HTML string into a document fragment.
821
+ *
822
+ * @param {string} htmlString The HTML string to convert.
823
+ * @return {!Node} The resulting document fragment.
824
+ */
825
+ goog.dom.htmlToDocumentFragment = function(htmlString) {
826
+ return goog.dom.htmlToDocumentFragment_(document, htmlString);
827
+ };
828
+
829
+
830
+ /**
831
+ * Helper for {@code htmlToDocumentFragment}.
832
+ *
833
+ * @param {!Document} doc The document.
834
+ * @param {string} htmlString The HTML string to convert.
835
+ * @return {!Node} The resulting document fragment.
836
+ * @private
837
+ */
838
+ goog.dom.htmlToDocumentFragment_ = function(doc, htmlString) {
839
+ var tempDiv = doc.createElement('div');
840
+ if (goog.dom.BrowserFeature.INNER_HTML_NEEDS_SCOPED_ELEMENT) {
841
+ tempDiv.innerHTML = '<br>' + htmlString;
842
+ tempDiv.removeChild(tempDiv.firstChild);
843
+ } else {
844
+ tempDiv.innerHTML = htmlString;
845
+ }
846
+ if (tempDiv.childNodes.length == 1) {
847
+ return /** @type {!Node} */ (tempDiv.removeChild(tempDiv.firstChild));
848
+ } else {
849
+ var fragment = doc.createDocumentFragment();
850
+ while (tempDiv.firstChild) {
851
+ fragment.appendChild(tempDiv.firstChild);
852
+ }
853
+ return fragment;
854
+ }
855
+ };
856
+
857
+
858
+ /**
859
+ * Returns the compatMode of the document.
860
+ * @return {string} The result is either CSS1Compat or BackCompat.
861
+ * @deprecated use goog.dom.isCss1CompatMode instead.
862
+ */
863
+ goog.dom.getCompatMode = function() {
864
+ return goog.dom.isCss1CompatMode() ? 'CSS1Compat' : 'BackCompat';
865
+ };
866
+
867
+
868
+ /**
869
+ * Returns true if the browser is in "CSS1-compatible" (standards-compliant)
870
+ * mode, false otherwise.
871
+ * @return {boolean} True if in CSS1-compatible mode.
872
+ */
873
+ goog.dom.isCss1CompatMode = function() {
874
+ return goog.dom.isCss1CompatMode_(document);
875
+ };
876
+
877
+
878
+ /**
879
+ * Returns true if the browser is in "CSS1-compatible" (standards-compliant)
880
+ * mode, false otherwise.
881
+ * @param {Document} doc The document to check.
882
+ * @return {boolean} True if in CSS1-compatible mode.
883
+ * @private
884
+ */
885
+ goog.dom.isCss1CompatMode_ = function(doc) {
886
+ if (goog.dom.COMPAT_MODE_KNOWN_) {
887
+ return goog.dom.ASSUME_STANDARDS_MODE;
888
+ }
889
+
890
+ return doc.compatMode == 'CSS1Compat';
891
+ };
892
+
893
+
894
+ /**
895
+ * Determines if the given node can contain children, intended to be used for
896
+ * HTML generation.
897
+ *
898
+ * IE natively supports node.canHaveChildren but has inconsistent behavior.
899
+ * Prior to IE8 the base tag allows children and in IE9 all nodes return true
900
+ * for canHaveChildren.
901
+ *
902
+ * In practice all non-IE browsers allow you to add children to any node, but
903
+ * the behavior is inconsistent:
904
+ *
905
+ * <pre>
906
+ * var a = document.createElement('br');
907
+ * a.appendChild(document.createTextNode('foo'));
908
+ * a.appendChild(document.createTextNode('bar'));
909
+ * console.log(a.childNodes.length); // 2
910
+ * console.log(a.innerHTML); // Chrome: "", IE9: "foobar", FF3.5: "foobar"
911
+ * </pre>
912
+ *
913
+ * TODO(user): Rename shouldAllowChildren() ?
914
+ *
915
+ * @param {Node} node The node to check.
916
+ * @return {boolean} Whether the node can contain children.
917
+ */
918
+ goog.dom.canHaveChildren = function(node) {
919
+ if (node.nodeType != goog.dom.NodeType.ELEMENT) {
920
+ return false;
921
+ }
922
+ switch (node.tagName) {
923
+ case goog.dom.TagName.APPLET:
924
+ case goog.dom.TagName.AREA:
925
+ case goog.dom.TagName.BASE:
926
+ case goog.dom.TagName.BR:
927
+ case goog.dom.TagName.COL:
928
+ case goog.dom.TagName.FRAME:
929
+ case goog.dom.TagName.HR:
930
+ case goog.dom.TagName.IMG:
931
+ case goog.dom.TagName.INPUT:
932
+ case goog.dom.TagName.IFRAME:
933
+ case goog.dom.TagName.ISINDEX:
934
+ case goog.dom.TagName.LINK:
935
+ case goog.dom.TagName.NOFRAMES:
936
+ case goog.dom.TagName.NOSCRIPT:
937
+ case goog.dom.TagName.META:
938
+ case goog.dom.TagName.OBJECT:
939
+ case goog.dom.TagName.PARAM:
940
+ case goog.dom.TagName.SCRIPT:
941
+ case goog.dom.TagName.STYLE:
942
+ return false;
943
+ }
944
+ return true;
945
+ };
946
+
947
+
948
+ /**
949
+ * Appends a child to a node.
950
+ * @param {Node} parent Parent.
951
+ * @param {Node} child Child.
952
+ */
953
+ goog.dom.appendChild = function(parent, child) {
954
+ parent.appendChild(child);
955
+ };
956
+
957
+
958
+ /**
959
+ * Appends a node with text or other nodes.
960
+ * @param {!Node} parent The node to append nodes to.
961
+ * @param {...goog.dom.Appendable} var_args The things to append to the node.
962
+ * If this is a Node it is appended as is.
963
+ * If this is a string then a text node is appended.
964
+ * If this is an array like object then fields 0 to length - 1 are appended.
965
+ */
966
+ goog.dom.append = function(parent, var_args) {
967
+ goog.dom.append_(goog.dom.getOwnerDocument(parent), parent, arguments, 1);
968
+ };
969
+
970
+
971
+ /**
972
+ * Removes all the child nodes on a DOM node.
973
+ * @param {Node} node Node to remove children from.
974
+ */
975
+ goog.dom.removeChildren = function(node) {
976
+ // Note: Iterations over live collections can be slow, this is the fastest
977
+ // we could find. The double parenthesis are used to prevent JsCompiler and
978
+ // strict warnings.
979
+ var child;
980
+ while ((child = node.firstChild)) {
981
+ node.removeChild(child);
982
+ }
983
+ };
984
+
985
+
986
+ /**
987
+ * Inserts a new node before an existing reference node (i.e. as the previous
988
+ * sibling). If the reference node has no parent, then does nothing.
989
+ * @param {Node} newNode Node to insert.
990
+ * @param {Node} refNode Reference node to insert before.
991
+ */
992
+ goog.dom.insertSiblingBefore = function(newNode, refNode) {
993
+ if (refNode.parentNode) {
994
+ refNode.parentNode.insertBefore(newNode, refNode);
995
+ }
996
+ };
997
+
998
+
999
+ /**
1000
+ * Inserts a new node after an existing reference node (i.e. as the next
1001
+ * sibling). If the reference node has no parent, then does nothing.
1002
+ * @param {Node} newNode Node to insert.
1003
+ * @param {Node} refNode Reference node to insert after.
1004
+ */
1005
+ goog.dom.insertSiblingAfter = function(newNode, refNode) {
1006
+ if (refNode.parentNode) {
1007
+ refNode.parentNode.insertBefore(newNode, refNode.nextSibling);
1008
+ }
1009
+ };
1010
+
1011
+
1012
+ /**
1013
+ * Insert a child at a given index. If index is larger than the number of child
1014
+ * nodes that the parent currently has, the node is inserted as the last child
1015
+ * node.
1016
+ * @param {Element} parent The element into which to insert the child.
1017
+ * @param {Node} child The element to insert.
1018
+ * @param {number} index The index at which to insert the new child node. Must
1019
+ * not be negative.
1020
+ */
1021
+ goog.dom.insertChildAt = function(parent, child, index) {
1022
+ // Note that if the second argument is null, insertBefore
1023
+ // will append the child at the end of the list of children.
1024
+ parent.insertBefore(child, parent.childNodes[index] || null);
1025
+ };
1026
+
1027
+
1028
+ /**
1029
+ * Removes a node from its parent.
1030
+ * @param {Node} node The node to remove.
1031
+ * @return {Node} The node removed if removed; else, null.
1032
+ */
1033
+ goog.dom.removeNode = function(node) {
1034
+ return node && node.parentNode ? node.parentNode.removeChild(node) : null;
1035
+ };
1036
+
1037
+
1038
+ /**
1039
+ * Replaces a node in the DOM tree. Will do nothing if {@code oldNode} has no
1040
+ * parent.
1041
+ * @param {Node} newNode Node to insert.
1042
+ * @param {Node} oldNode Node to replace.
1043
+ */
1044
+ goog.dom.replaceNode = function(newNode, oldNode) {
1045
+ var parent = oldNode.parentNode;
1046
+ if (parent) {
1047
+ parent.replaceChild(newNode, oldNode);
1048
+ }
1049
+ };
1050
+
1051
+
1052
+ /**
1053
+ * Flattens an element. That is, removes it and replace it with its children.
1054
+ * Does nothing if the element is not in the document.
1055
+ * @param {Element} element The element to flatten.
1056
+ * @return {Element|undefined} The original element, detached from the document
1057
+ * tree, sans children; or undefined, if the element was not in the
1058
+ * document to begin with.
1059
+ */
1060
+ goog.dom.flattenElement = function(element) {
1061
+ var child, parent = element.parentNode;
1062
+ if (parent && parent.nodeType != goog.dom.NodeType.DOCUMENT_FRAGMENT) {
1063
+ // Use IE DOM method (supported by Opera too) if available
1064
+ if (element.removeNode) {
1065
+ return /** @type {Element} */ (element.removeNode(false));
1066
+ } else {
1067
+ // Move all children of the original node up one level.
1068
+ while ((child = element.firstChild)) {
1069
+ parent.insertBefore(child, element);
1070
+ }
1071
+
1072
+ // Detach the original element.
1073
+ return /** @type {Element} */ (goog.dom.removeNode(element));
1074
+ }
1075
+ }
1076
+ };
1077
+
1078
+
1079
+ /**
1080
+ * Returns an array containing just the element children of the given element.
1081
+ * @param {Element} element The element whose element children we want.
1082
+ * @return {Array|NodeList} An array or array-like list of just the element
1083
+ * children of the given element.
1084
+ */
1085
+ goog.dom.getChildren = function(element) {
1086
+ // We check if the children attribute is supported for child elements
1087
+ // since IE8 misuses the attribute by also including comments.
1088
+ if (goog.dom.BrowserFeature.CAN_USE_CHILDREN_ATTRIBUTE &&
1089
+ element.children != undefined) {
1090
+ return element.children;
1091
+ }
1092
+ // Fall back to manually filtering the element's child nodes.
1093
+ return goog.array.filter(element.childNodes, function(node) {
1094
+ return node.nodeType == goog.dom.NodeType.ELEMENT;
1095
+ });
1096
+ };
1097
+
1098
+
1099
+ /**
1100
+ * Returns the first child node that is an element.
1101
+ * @param {Node} node The node to get the first child element of.
1102
+ * @return {Element} The first child node of {@code node} that is an element.
1103
+ */
1104
+ goog.dom.getFirstElementChild = function(node) {
1105
+ if (node.firstElementChild != undefined) {
1106
+ return /** @type {Element} */(node).firstElementChild;
1107
+ }
1108
+ return goog.dom.getNextElementNode_(node.firstChild, true);
1109
+ };
1110
+
1111
+
1112
+ /**
1113
+ * Returns the last child node that is an element.
1114
+ * @param {Node} node The node to get the last child element of.
1115
+ * @return {Element} The last child node of {@code node} that is an element.
1116
+ */
1117
+ goog.dom.getLastElementChild = function(node) {
1118
+ if (node.lastElementChild != undefined) {
1119
+ return /** @type {Element} */(node).lastElementChild;
1120
+ }
1121
+ return goog.dom.getNextElementNode_(node.lastChild, false);
1122
+ };
1123
+
1124
+
1125
+ /**
1126
+ * Returns the first next sibling that is an element.
1127
+ * @param {Node} node The node to get the next sibling element of.
1128
+ * @return {Element} The next sibling of {@code node} that is an element.
1129
+ */
1130
+ goog.dom.getNextElementSibling = function(node) {
1131
+ if (node.nextElementSibling != undefined) {
1132
+ return /** @type {Element} */(node).nextElementSibling;
1133
+ }
1134
+ return goog.dom.getNextElementNode_(node.nextSibling, true);
1135
+ };
1136
+
1137
+
1138
+ /**
1139
+ * Returns the first previous sibling that is an element.
1140
+ * @param {Node} node The node to get the previous sibling element of.
1141
+ * @return {Element} The first previous sibling of {@code node} that is
1142
+ * an element.
1143
+ */
1144
+ goog.dom.getPreviousElementSibling = function(node) {
1145
+ if (node.previousElementSibling != undefined) {
1146
+ return /** @type {Element} */(node).previousElementSibling;
1147
+ }
1148
+ return goog.dom.getNextElementNode_(node.previousSibling, false);
1149
+ };
1150
+
1151
+
1152
+ /**
1153
+ * Returns the first node that is an element in the specified direction,
1154
+ * starting with {@code node}.
1155
+ * @param {Node} node The node to get the next element from.
1156
+ * @param {boolean} forward Whether to look forwards or backwards.
1157
+ * @return {Element} The first element.
1158
+ * @private
1159
+ */
1160
+ goog.dom.getNextElementNode_ = function(node, forward) {
1161
+ while (node && node.nodeType != goog.dom.NodeType.ELEMENT) {
1162
+ node = forward ? node.nextSibling : node.previousSibling;
1163
+ }
1164
+
1165
+ return /** @type {Element} */ (node);
1166
+ };
1167
+
1168
+
1169
+ /**
1170
+ * Returns the next node in source order from the given node.
1171
+ * @param {Node} node The node.
1172
+ * @return {Node} The next node in the DOM tree, or null if this was the last
1173
+ * node.
1174
+ */
1175
+ goog.dom.getNextNode = function(node) {
1176
+ if (!node) {
1177
+ return null;
1178
+ }
1179
+
1180
+ if (node.firstChild) {
1181
+ return node.firstChild;
1182
+ }
1183
+
1184
+ while (node && !node.nextSibling) {
1185
+ node = node.parentNode;
1186
+ }
1187
+
1188
+ return node ? node.nextSibling : null;
1189
+ };
1190
+
1191
+
1192
+ /**
1193
+ * Returns the previous node in source order from the given node.
1194
+ * @param {Node} node The node.
1195
+ * @return {Node} The previous node in the DOM tree, or null if this was the
1196
+ * first node.
1197
+ */
1198
+ goog.dom.getPreviousNode = function(node) {
1199
+ if (!node) {
1200
+ return null;
1201
+ }
1202
+
1203
+ if (!node.previousSibling) {
1204
+ return node.parentNode;
1205
+ }
1206
+
1207
+ node = node.previousSibling;
1208
+ while (node && node.lastChild) {
1209
+ node = node.lastChild;
1210
+ }
1211
+
1212
+ return node;
1213
+ };
1214
+
1215
+
1216
+ /**
1217
+ * Whether the object looks like a DOM node.
1218
+ * @param {*} obj The object being tested for node likeness.
1219
+ * @return {boolean} Whether the object looks like a DOM node.
1220
+ */
1221
+ goog.dom.isNodeLike = function(obj) {
1222
+ return goog.isObject(obj) && obj.nodeType > 0;
1223
+ };
1224
+
1225
+
1226
+ /**
1227
+ * Whether the object looks like an Element.
1228
+ * @param {*} obj The object being tested for Element likeness.
1229
+ * @return {boolean} Whether the object looks like an Element.
1230
+ */
1231
+ goog.dom.isElement = function(obj) {
1232
+ return goog.isObject(obj) && obj.nodeType == goog.dom.NodeType.ELEMENT;
1233
+ };
1234
+
1235
+
1236
+ /**
1237
+ * Returns true if the specified value is a Window object. This includes the
1238
+ * global window for HTML pages, and iframe windows.
1239
+ * @param {*} obj Variable to test.
1240
+ * @return {boolean} Whether the variable is a window.
1241
+ */
1242
+ goog.dom.isWindow = function(obj) {
1243
+ return goog.isObject(obj) && obj['window'] == obj;
1244
+ };
1245
+
1246
+
1247
+ /**
1248
+ * Returns an element's parent, if it's an Element.
1249
+ * @param {Element} element The DOM element.
1250
+ * @return {Element} The parent, or null if not an Element.
1251
+ */
1252
+ goog.dom.getParentElement = function(element) {
1253
+ if (goog.dom.BrowserFeature.CAN_USE_PARENT_ELEMENT_PROPERTY) {
1254
+ return element.parentElement;
1255
+ }
1256
+ var parent = element.parentNode;
1257
+ return goog.dom.isElement(parent) ? (/** @type {!Element} */ parent) : null;
1258
+ };
1259
+
1260
+
1261
+ /**
1262
+ * Whether a node contains another node.
1263
+ * @param {Node} parent The node that should contain the other node.
1264
+ * @param {Node} descendant The node to test presence of.
1265
+ * @return {boolean} Whether the parent node contains the descendent node.
1266
+ */
1267
+ goog.dom.contains = function(parent, descendant) {
1268
+ // We use browser specific methods for this if available since it is faster
1269
+ // that way.
1270
+
1271
+ // IE DOM
1272
+ if (parent.contains && descendant.nodeType == goog.dom.NodeType.ELEMENT) {
1273
+ return parent == descendant || parent.contains(descendant);
1274
+ }
1275
+
1276
+ // W3C DOM Level 3
1277
+ if (typeof parent.compareDocumentPosition != 'undefined') {
1278
+ return parent == descendant ||
1279
+ Boolean(parent.compareDocumentPosition(descendant) & 16);
1280
+ }
1281
+
1282
+ // W3C DOM Level 1
1283
+ while (descendant && parent != descendant) {
1284
+ descendant = descendant.parentNode;
1285
+ }
1286
+ return descendant == parent;
1287
+ };
1288
+
1289
+
1290
+ /**
1291
+ * Compares the document order of two nodes, returning 0 if they are the same
1292
+ * node, a negative number if node1 is before node2, and a positive number if
1293
+ * node2 is before node1. Note that we compare the order the tags appear in the
1294
+ * document so in the tree <b><i>text</i></b> the B node is considered to be
1295
+ * before the I node.
1296
+ *
1297
+ * @param {Node} node1 The first node to compare.
1298
+ * @param {Node} node2 The second node to compare.
1299
+ * @return {number} 0 if the nodes are the same node, a negative number if node1
1300
+ * is before node2, and a positive number if node2 is before node1.
1301
+ */
1302
+ goog.dom.compareNodeOrder = function(node1, node2) {
1303
+ // Fall out quickly for equality.
1304
+ if (node1 == node2) {
1305
+ return 0;
1306
+ }
1307
+
1308
+ // Use compareDocumentPosition where available
1309
+ if (node1.compareDocumentPosition) {
1310
+ // 4 is the bitmask for FOLLOWS.
1311
+ return node1.compareDocumentPosition(node2) & 2 ? 1 : -1;
1312
+ }
1313
+
1314
+ // Process in IE using sourceIndex - we check to see if the first node has
1315
+ // a source index or if its parent has one.
1316
+ if ('sourceIndex' in node1 ||
1317
+ (node1.parentNode && 'sourceIndex' in node1.parentNode)) {
1318
+ var isElement1 = node1.nodeType == goog.dom.NodeType.ELEMENT;
1319
+ var isElement2 = node2.nodeType == goog.dom.NodeType.ELEMENT;
1320
+
1321
+ if (isElement1 && isElement2) {
1322
+ return node1.sourceIndex - node2.sourceIndex;
1323
+ } else {
1324
+ var parent1 = node1.parentNode;
1325
+ var parent2 = node2.parentNode;
1326
+
1327
+ if (parent1 == parent2) {
1328
+ return goog.dom.compareSiblingOrder_(node1, node2);
1329
+ }
1330
+
1331
+ if (!isElement1 && goog.dom.contains(parent1, node2)) {
1332
+ return -1 * goog.dom.compareParentsDescendantNodeIe_(node1, node2);
1333
+ }
1334
+
1335
+
1336
+ if (!isElement2 && goog.dom.contains(parent2, node1)) {
1337
+ return goog.dom.compareParentsDescendantNodeIe_(node2, node1);
1338
+ }
1339
+
1340
+ return (isElement1 ? node1.sourceIndex : parent1.sourceIndex) -
1341
+ (isElement2 ? node2.sourceIndex : parent2.sourceIndex);
1342
+ }
1343
+ }
1344
+
1345
+ // For Safari, we compare ranges.
1346
+ var doc = goog.dom.getOwnerDocument(node1);
1347
+
1348
+ var range1, range2;
1349
+ range1 = doc.createRange();
1350
+ range1.selectNode(node1);
1351
+ range1.collapse(true);
1352
+
1353
+ range2 = doc.createRange();
1354
+ range2.selectNode(node2);
1355
+ range2.collapse(true);
1356
+
1357
+ return range1.compareBoundaryPoints(goog.global['Range'].START_TO_END,
1358
+ range2);
1359
+ };
1360
+
1361
+
1362
+ /**
1363
+ * Utility function to compare the position of two nodes, when
1364
+ * {@code textNode}'s parent is an ancestor of {@code node}. If this entry
1365
+ * condition is not met, this function will attempt to reference a null object.
1366
+ * @param {Node} textNode The textNode to compare.
1367
+ * @param {Node} node The node to compare.
1368
+ * @return {number} -1 if node is before textNode, +1 otherwise.
1369
+ * @private
1370
+ */
1371
+ goog.dom.compareParentsDescendantNodeIe_ = function(textNode, node) {
1372
+ var parent = textNode.parentNode;
1373
+ if (parent == node) {
1374
+ // If textNode is a child of node, then node comes first.
1375
+ return -1;
1376
+ }
1377
+ var sibling = node;
1378
+ while (sibling.parentNode != parent) {
1379
+ sibling = sibling.parentNode;
1380
+ }
1381
+ return goog.dom.compareSiblingOrder_(sibling, textNode);
1382
+ };
1383
+
1384
+
1385
+ /**
1386
+ * Utility function to compare the position of two nodes known to be non-equal
1387
+ * siblings.
1388
+ * @param {Node} node1 The first node to compare.
1389
+ * @param {Node} node2 The second node to compare.
1390
+ * @return {number} -1 if node1 is before node2, +1 otherwise.
1391
+ * @private
1392
+ */
1393
+ goog.dom.compareSiblingOrder_ = function(node1, node2) {
1394
+ var s = node2;
1395
+ while ((s = s.previousSibling)) {
1396
+ if (s == node1) {
1397
+ // We just found node1 before node2.
1398
+ return -1;
1399
+ }
1400
+ }
1401
+
1402
+ // Since we didn't find it, node1 must be after node2.
1403
+ return 1;
1404
+ };
1405
+
1406
+
1407
+ /**
1408
+ * Find the deepest common ancestor of the given nodes.
1409
+ * @param {...Node} var_args The nodes to find a common ancestor of.
1410
+ * @return {Node} The common ancestor of the nodes, or null if there is none.
1411
+ * null will only be returned if two or more of the nodes are from different
1412
+ * documents.
1413
+ */
1414
+ goog.dom.findCommonAncestor = function(var_args) {
1415
+ var i, count = arguments.length;
1416
+ if (!count) {
1417
+ return null;
1418
+ } else if (count == 1) {
1419
+ return arguments[0];
1420
+ }
1421
+
1422
+ var paths = [];
1423
+ var minLength = Infinity;
1424
+ for (i = 0; i < count; i++) {
1425
+ // Compute the list of ancestors.
1426
+ var ancestors = [];
1427
+ var node = arguments[i];
1428
+ while (node) {
1429
+ ancestors.unshift(node);
1430
+ node = node.parentNode;
1431
+ }
1432
+
1433
+ // Save the list for comparison.
1434
+ paths.push(ancestors);
1435
+ minLength = Math.min(minLength, ancestors.length);
1436
+ }
1437
+ var output = null;
1438
+ for (i = 0; i < minLength; i++) {
1439
+ var first = paths[0][i];
1440
+ for (var j = 1; j < count; j++) {
1441
+ if (first != paths[j][i]) {
1442
+ return output;
1443
+ }
1444
+ }
1445
+ output = first;
1446
+ }
1447
+ return output;
1448
+ };
1449
+
1450
+
1451
+ /**
1452
+ * Returns the owner document for a node.
1453
+ * @param {Node|Window} node The node to get the document for.
1454
+ * @return {!Document} The document owning the node.
1455
+ */
1456
+ goog.dom.getOwnerDocument = function(node) {
1457
+ // TODO(arv): Remove IE5 code.
1458
+ // IE5 uses document instead of ownerDocument
1459
+ return /** @type {!Document} */ (
1460
+ node.nodeType == goog.dom.NodeType.DOCUMENT ? node :
1461
+ node.ownerDocument || node.document);
1462
+ };
1463
+
1464
+
1465
+ /**
1466
+ * Cross-browser function for getting the document element of a frame or iframe.
1467
+ * @param {Element} frame Frame element.
1468
+ * @return {!Document} The frame content document.
1469
+ */
1470
+ goog.dom.getFrameContentDocument = function(frame) {
1471
+ var doc = frame.contentDocument || frame.contentWindow.document;
1472
+ return doc;
1473
+ };
1474
+
1475
+
1476
+ /**
1477
+ * Cross-browser function for getting the window of a frame or iframe.
1478
+ * @param {HTMLIFrameElement|HTMLFrameElement} frame Frame element.
1479
+ * @return {Window} The window associated with the given frame.
1480
+ */
1481
+ goog.dom.getFrameContentWindow = function(frame) {
1482
+ return frame.contentWindow ||
1483
+ goog.dom.getWindow_(goog.dom.getFrameContentDocument(frame));
1484
+ };
1485
+
1486
+
1487
+ /**
1488
+ * Cross-browser function for setting the text content of an element.
1489
+ * @param {Element} element The element to change the text content of.
1490
+ * @param {string} text The string that should replace the current element
1491
+ * content.
1492
+ */
1493
+ goog.dom.setTextContent = function(element, text) {
1494
+ if ('textContent' in element) {
1495
+ element.textContent = text;
1496
+ } else if (element.firstChild &&
1497
+ element.firstChild.nodeType == goog.dom.NodeType.TEXT) {
1498
+ // If the first child is a text node we just change its data and remove the
1499
+ // rest of the children.
1500
+ while (element.lastChild != element.firstChild) {
1501
+ element.removeChild(element.lastChild);
1502
+ }
1503
+ element.firstChild.data = text;
1504
+ } else {
1505
+ goog.dom.removeChildren(element);
1506
+ var doc = goog.dom.getOwnerDocument(element);
1507
+ element.appendChild(doc.createTextNode(text));
1508
+ }
1509
+ };
1510
+
1511
+
1512
+ /**
1513
+ * Gets the outerHTML of a node, which islike innerHTML, except that it
1514
+ * actually contains the HTML of the node itself.
1515
+ * @param {Element} element The element to get the HTML of.
1516
+ * @return {string} The outerHTML of the given element.
1517
+ */
1518
+ goog.dom.getOuterHtml = function(element) {
1519
+ // IE, Opera and WebKit all have outerHTML.
1520
+ if ('outerHTML' in element) {
1521
+ return element.outerHTML;
1522
+ } else {
1523
+ var doc = goog.dom.getOwnerDocument(element);
1524
+ var div = doc.createElement('div');
1525
+ div.appendChild(element.cloneNode(true));
1526
+ return div.innerHTML;
1527
+ }
1528
+ };
1529
+
1530
+
1531
+ /**
1532
+ * Finds the first descendant node that matches the filter function, using
1533
+ * a depth first search. This function offers the most general purpose way
1534
+ * of finding a matching element. You may also wish to consider
1535
+ * {@code goog.dom.query} which can express many matching criteria using
1536
+ * CSS selector expressions. These expressions often result in a more
1537
+ * compact representation of the desired result.
1538
+ * @see goog.dom.query
1539
+ *
1540
+ * @param {Node} root The root of the tree to search.
1541
+ * @param {function(Node) : boolean} p The filter function.
1542
+ * @return {Node|undefined} The found node or undefined if none is found.
1543
+ */
1544
+ goog.dom.findNode = function(root, p) {
1545
+ var rv = [];
1546
+ var found = goog.dom.findNodes_(root, p, rv, true);
1547
+ return found ? rv[0] : undefined;
1548
+ };
1549
+
1550
+
1551
+ /**
1552
+ * Finds all the descendant nodes that match the filter function, using a
1553
+ * a depth first search. This function offers the most general-purpose way
1554
+ * of finding a set of matching elements. You may also wish to consider
1555
+ * {@code goog.dom.query} which can express many matching criteria using
1556
+ * CSS selector expressions. These expressions often result in a more
1557
+ * compact representation of the desired result.
1558
+
1559
+ * @param {Node} root The root of the tree to search.
1560
+ * @param {function(Node) : boolean} p The filter function.
1561
+ * @return {Array.<Node>} The found nodes or an empty array if none are found.
1562
+ */
1563
+ goog.dom.findNodes = function(root, p) {
1564
+ var rv = [];
1565
+ goog.dom.findNodes_(root, p, rv, false);
1566
+ return rv;
1567
+ };
1568
+
1569
+
1570
+ /**
1571
+ * Finds the first or all the descendant nodes that match the filter function,
1572
+ * using a depth first search.
1573
+ * @param {Node} root The root of the tree to search.
1574
+ * @param {function(Node) : boolean} p The filter function.
1575
+ * @param {Array.<Node>} rv The found nodes are added to this array.
1576
+ * @param {boolean} findOne If true we exit after the first found node.
1577
+ * @return {boolean} Whether the search is complete or not. True in case findOne
1578
+ * is true and the node is found. False otherwise.
1579
+ * @private
1580
+ */
1581
+ goog.dom.findNodes_ = function(root, p, rv, findOne) {
1582
+ if (root != null) {
1583
+ var child = root.firstChild;
1584
+ while (child) {
1585
+ if (p(child)) {
1586
+ rv.push(child);
1587
+ if (findOne) {
1588
+ return true;
1589
+ }
1590
+ }
1591
+ if (goog.dom.findNodes_(child, p, rv, findOne)) {
1592
+ return true;
1593
+ }
1594
+ child = child.nextSibling;
1595
+ }
1596
+ }
1597
+ return false;
1598
+ };
1599
+
1600
+
1601
+ /**
1602
+ * Map of tags whose content to ignore when calculating text length.
1603
+ * @type {Object}
1604
+ * @private
1605
+ */
1606
+ goog.dom.TAGS_TO_IGNORE_ = {
1607
+ 'SCRIPT': 1,
1608
+ 'STYLE': 1,
1609
+ 'HEAD': 1,
1610
+ 'IFRAME': 1,
1611
+ 'OBJECT': 1
1612
+ };
1613
+
1614
+
1615
+ /**
1616
+ * Map of tags which have predefined values with regard to whitespace.
1617
+ * @type {Object}
1618
+ * @private
1619
+ */
1620
+ goog.dom.PREDEFINED_TAG_VALUES_ = {'IMG': ' ', 'BR': '\n'};
1621
+
1622
+
1623
+ /**
1624
+ * Returns true if the element has a tab index that allows it to receive
1625
+ * keyboard focus (tabIndex >= 0), false otherwise. Note that form elements
1626
+ * natively support keyboard focus, even if they have no tab index.
1627
+ * @param {Element} element Element to check.
1628
+ * @return {boolean} Whether the element has a tab index that allows keyboard
1629
+ * focus.
1630
+ * @see http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
1631
+ */
1632
+ goog.dom.isFocusableTabIndex = function(element) {
1633
+ // IE returns 0 for an unset tabIndex, so we must use getAttributeNode(),
1634
+ // which returns an object with a 'specified' property if tabIndex is
1635
+ // specified. This works on other browsers, too.
1636
+ var attrNode = element.getAttributeNode('tabindex'); // Must be lowercase!
1637
+ if (attrNode && attrNode.specified) {
1638
+ var index = element.tabIndex;
1639
+ // NOTE: IE9 puts tabIndex in 16-bit int, e.g. -2 is 65534.
1640
+ return goog.isNumber(index) && index >= 0 && index < 32768;
1641
+ }
1642
+ return false;
1643
+ };
1644
+
1645
+
1646
+ /**
1647
+ * Enables or disables keyboard focus support on the element via its tab index.
1648
+ * Only elements for which {@link goog.dom.isFocusableTabIndex} returns true
1649
+ * (or elements that natively support keyboard focus, like form elements) can
1650
+ * receive keyboard focus. See http://go/tabindex for more info.
1651
+ * @param {Element} element Element whose tab index is to be changed.
1652
+ * @param {boolean} enable Whether to set or remove a tab index on the element
1653
+ * that supports keyboard focus.
1654
+ */
1655
+ goog.dom.setFocusableTabIndex = function(element, enable) {
1656
+ if (enable) {
1657
+ element.tabIndex = 0;
1658
+ } else {
1659
+ // Set tabIndex to -1 first, then remove it. This is a workaround for
1660
+ // Safari (confirmed in version 4 on Windows). When removing the attribute
1661
+ // without setting it to -1 first, the element remains keyboard focusable
1662
+ // despite not having a tabIndex attribute anymore.
1663
+ element.tabIndex = -1;
1664
+ element.removeAttribute('tabIndex'); // Must be camelCase!
1665
+ }
1666
+ };
1667
+
1668
+
1669
+ /**
1670
+ * Returns the text content of the current node, without markup and invisible
1671
+ * symbols. New lines are stripped and whitespace is collapsed,
1672
+ * such that each character would be visible.
1673
+ *
1674
+ * In browsers that support it, innerText is used. Other browsers attempt to
1675
+ * simulate it via node traversal. Line breaks are canonicalized in IE.
1676
+ *
1677
+ * @param {Node} node The node from which we are getting content.
1678
+ * @return {string} The text content.
1679
+ */
1680
+ goog.dom.getTextContent = function(node) {
1681
+ var textContent;
1682
+ // Note(arv): IE9, Opera, and Safari 3 support innerText but they include
1683
+ // text nodes in script tags. So we revert to use a user agent test here.
1684
+ if (goog.dom.BrowserFeature.CAN_USE_INNER_TEXT && ('innerText' in node)) {
1685
+ textContent = goog.string.canonicalizeNewlines(node.innerText);
1686
+ // Unfortunately .innerText() returns text with &shy; symbols
1687
+ // We need to filter it out and then remove duplicate whitespaces
1688
+ } else {
1689
+ var buf = [];
1690
+ goog.dom.getTextContent_(node, buf, true);
1691
+ textContent = buf.join('');
1692
+ }
1693
+
1694
+ // Strip &shy; entities. goog.format.insertWordBreaks inserts them in Opera.
1695
+ textContent = textContent.replace(/ \xAD /g, ' ').replace(/\xAD/g, '');
1696
+ // Strip &#8203; entities. goog.format.insertWordBreaks inserts them in IE8.
1697
+ textContent = textContent.replace(/\u200B/g, '');
1698
+
1699
+ // Skip this replacement on old browsers with working innerText, which
1700
+ // automatically turns &nbsp; into ' ' and / +/ into ' ' when reading
1701
+ // innerText.
1702
+ if (!goog.dom.BrowserFeature.CAN_USE_INNER_TEXT) {
1703
+ textContent = textContent.replace(/ +/g, ' ');
1704
+ }
1705
+ if (textContent != ' ') {
1706
+ textContent = textContent.replace(/^\s*/, '');
1707
+ }
1708
+
1709
+ return textContent;
1710
+ };
1711
+
1712
+
1713
+ /**
1714
+ * Returns the text content of the current node, without markup.
1715
+ *
1716
+ * Unlike {@code getTextContent} this method does not collapse whitespaces
1717
+ * or normalize lines breaks.
1718
+ *
1719
+ * @param {Node} node The node from which we are getting content.
1720
+ * @return {string} The raw text content.
1721
+ */
1722
+ goog.dom.getRawTextContent = function(node) {
1723
+ var buf = [];
1724
+ goog.dom.getTextContent_(node, buf, false);
1725
+
1726
+ return buf.join('');
1727
+ };
1728
+
1729
+
1730
+ /**
1731
+ * Recursive support function for text content retrieval.
1732
+ *
1733
+ * @param {Node} node The node from which we are getting content.
1734
+ * @param {Array} buf string buffer.
1735
+ * @param {boolean} normalizeWhitespace Whether to normalize whitespace.
1736
+ * @private
1737
+ */
1738
+ goog.dom.getTextContent_ = function(node, buf, normalizeWhitespace) {
1739
+ if (node.nodeName in goog.dom.TAGS_TO_IGNORE_) {
1740
+ // ignore certain tags
1741
+ } else if (node.nodeType == goog.dom.NodeType.TEXT) {
1742
+ if (normalizeWhitespace) {
1743
+ buf.push(String(node.nodeValue).replace(/(\r\n|\r|\n)/g, ''));
1744
+ } else {
1745
+ buf.push(node.nodeValue);
1746
+ }
1747
+ } else if (node.nodeName in goog.dom.PREDEFINED_TAG_VALUES_) {
1748
+ buf.push(goog.dom.PREDEFINED_TAG_VALUES_[node.nodeName]);
1749
+ } else {
1750
+ var child = node.firstChild;
1751
+ while (child) {
1752
+ goog.dom.getTextContent_(child, buf, normalizeWhitespace);
1753
+ child = child.nextSibling;
1754
+ }
1755
+ }
1756
+ };
1757
+
1758
+
1759
+ /**
1760
+ * Returns the text length of the text contained in a node, without markup. This
1761
+ * is equivalent to the selection length if the node was selected, or the number
1762
+ * of cursor movements to traverse the node. Images & BRs take one space. New
1763
+ * lines are ignored.
1764
+ *
1765
+ * @param {Node} node The node whose text content length is being calculated.
1766
+ * @return {number} The length of {@code node}'s text content.
1767
+ */
1768
+ goog.dom.getNodeTextLength = function(node) {
1769
+ return goog.dom.getTextContent(node).length;
1770
+ };
1771
+
1772
+
1773
+ /**
1774
+ * Returns the text offset of a node relative to one of its ancestors. The text
1775
+ * length is the same as the length calculated by goog.dom.getNodeTextLength.
1776
+ *
1777
+ * @param {Node} node The node whose offset is being calculated.
1778
+ * @param {Node=} opt_offsetParent The node relative to which the offset will
1779
+ * be calculated. Defaults to the node's owner document's body.
1780
+ * @return {number} The text offset.
1781
+ */
1782
+ goog.dom.getNodeTextOffset = function(node, opt_offsetParent) {
1783
+ var root = opt_offsetParent || goog.dom.getOwnerDocument(node).body;
1784
+ var buf = [];
1785
+ while (node && node != root) {
1786
+ var cur = node;
1787
+ while ((cur = cur.previousSibling)) {
1788
+ buf.unshift(goog.dom.getTextContent(cur));
1789
+ }
1790
+ node = node.parentNode;
1791
+ }
1792
+ // Trim left to deal with FF cases when there might be line breaks and empty
1793
+ // nodes at the front of the text
1794
+ return goog.string.trimLeft(buf.join('')).replace(/ +/g, ' ').length;
1795
+ };
1796
+
1797
+
1798
+ /**
1799
+ * Returns the node at a given offset in a parent node. If an object is
1800
+ * provided for the optional third parameter, the node and the remainder of the
1801
+ * offset will stored as properties of this object.
1802
+ * @param {Node} parent The parent node.
1803
+ * @param {number} offset The offset into the parent node.
1804
+ * @param {Object=} opt_result Object to be used to store the return value. The
1805
+ * return value will be stored in the form {node: Node, remainder: number}
1806
+ * if this object is provided.
1807
+ * @return {Node} The node at the given offset.
1808
+ */
1809
+ goog.dom.getNodeAtOffset = function(parent, offset, opt_result) {
1810
+ var stack = [parent], pos = 0, cur;
1811
+ while (stack.length > 0 && pos < offset) {
1812
+ cur = stack.pop();
1813
+ if (cur.nodeName in goog.dom.TAGS_TO_IGNORE_) {
1814
+ // ignore certain tags
1815
+ } else if (cur.nodeType == goog.dom.NodeType.TEXT) {
1816
+ var text = cur.nodeValue.replace(/(\r\n|\r|\n)/g, '').replace(/ +/g, ' ');
1817
+ pos += text.length;
1818
+ } else if (cur.nodeName in goog.dom.PREDEFINED_TAG_VALUES_) {
1819
+ pos += goog.dom.PREDEFINED_TAG_VALUES_[cur.nodeName].length;
1820
+ } else {
1821
+ for (var i = cur.childNodes.length - 1; i >= 0; i--) {
1822
+ stack.push(cur.childNodes[i]);
1823
+ }
1824
+ }
1825
+ }
1826
+ if (goog.isObject(opt_result)) {
1827
+ opt_result.remainder = cur ? cur.nodeValue.length + offset - pos - 1 : 0;
1828
+ opt_result.node = cur;
1829
+ }
1830
+
1831
+ return cur;
1832
+ };
1833
+
1834
+
1835
+ /**
1836
+ * Returns true if the object is a {@code NodeList}. To qualify as a NodeList,
1837
+ * the object must have a numeric length property and an item function (which
1838
+ * has type 'string' on IE for some reason).
1839
+ * @param {Object} val Object to test.
1840
+ * @return {boolean} Whether the object is a NodeList.
1841
+ */
1842
+ goog.dom.isNodeList = function(val) {
1843
+ // TODO(attila): Now the isNodeList is part of goog.dom we can use
1844
+ // goog.userAgent to make this simpler.
1845
+ // A NodeList must have a length property of type 'number' on all platforms.
1846
+ if (val && typeof val.length == 'number') {
1847
+ // A NodeList is an object everywhere except Safari, where it's a function.
1848
+ if (goog.isObject(val)) {
1849
+ // A NodeList must have an item function (on non-IE platforms) or an item
1850
+ // property of type 'string' (on IE).
1851
+ return typeof val.item == 'function' || typeof val.item == 'string';
1852
+ } else if (goog.isFunction(val)) {
1853
+ // On Safari, a NodeList is a function with an item property that is also
1854
+ // a function.
1855
+ return typeof val.item == 'function';
1856
+ }
1857
+ }
1858
+
1859
+ // Not a NodeList.
1860
+ return false;
1861
+ };
1862
+
1863
+
1864
+ /**
1865
+ * Walks up the DOM hierarchy returning the first ancestor that has the passed
1866
+ * tag name and/or class name. If the passed element matches the specified
1867
+ * criteria, the element itself is returned.
1868
+ * @param {Node} element The DOM node to start with.
1869
+ * @param {?string=} opt_tag The tag name to match (or null/undefined to match
1870
+ * any node regardless of tag name). Must be uppercase (goog.dom.TagName).
1871
+ * @param {?string=} opt_class The class name to match (or null/undefined to
1872
+ * match any node regardless of class name).
1873
+ * @return {Node} The first ancestor that matches the passed criteria, or
1874
+ * null if none match.
1875
+ */
1876
+ goog.dom.getAncestorByTagNameAndClass = function(element, opt_tag, opt_class) {
1877
+ var tagName = opt_tag ? opt_tag.toUpperCase() : null;
1878
+ return goog.dom.getAncestor(element,
1879
+ function(node) {
1880
+ return (!tagName || node.nodeName == tagName) &&
1881
+ (!opt_class || goog.dom.classes.has(node, opt_class));
1882
+ }, true);
1883
+ };
1884
+
1885
+
1886
+ /**
1887
+ * Walks up the DOM hierarchy returning the first ancestor that has the passed
1888
+ * class name. If the passed element matches the specified criteria, the
1889
+ * element itself is returned.
1890
+ * @param {Node} element The DOM node to start with.
1891
+ * @param {?string=} opt_class The class name to match (or null/undefined to
1892
+ * match any node regardless of class name).
1893
+ * @return {Node} The first ancestor that matches the passed criteria, or
1894
+ * null if none match.
1895
+ */
1896
+ goog.dom.getAncestorByClass = function(element, opt_class) {
1897
+ return goog.dom.getAncestorByTagNameAndClass(element, null, opt_class);
1898
+ };
1899
+
1900
+
1901
+ /**
1902
+ * Walks up the DOM hierarchy returning the first ancestor that passes the
1903
+ * matcher function.
1904
+ * @param {Node} element The DOM node to start with.
1905
+ * @param {function(Node) : boolean} matcher A function that returns true if the
1906
+ * passed node matches the desired criteria.
1907
+ * @param {boolean=} opt_includeNode If true, the node itself is included in
1908
+ * the search (the first call to the matcher will pass startElement as
1909
+ * the node to test).
1910
+ * @param {number=} opt_maxSearchSteps Maximum number of levels to search up the
1911
+ * dom.
1912
+ * @return {Node} DOM node that matched the matcher, or null if there was
1913
+ * no match.
1914
+ */
1915
+ goog.dom.getAncestor = function(
1916
+ element, matcher, opt_includeNode, opt_maxSearchSteps) {
1917
+ if (!opt_includeNode) {
1918
+ element = element.parentNode;
1919
+ }
1920
+ var ignoreSearchSteps = opt_maxSearchSteps == null;
1921
+ var steps = 0;
1922
+ while (element && (ignoreSearchSteps || steps <= opt_maxSearchSteps)) {
1923
+ if (matcher(element)) {
1924
+ return element;
1925
+ }
1926
+ element = element.parentNode;
1927
+ steps++;
1928
+ }
1929
+ // Reached the root of the DOM without a match
1930
+ return null;
1931
+ };
1932
+
1933
+
1934
+ /**
1935
+ * Determines the active element in the given document.
1936
+ * @param {Document} doc The document to look in.
1937
+ * @return {Element} The active element.
1938
+ */
1939
+ goog.dom.getActiveElement = function(doc) {
1940
+ try {
1941
+ return doc && doc.activeElement;
1942
+ } catch (e) {
1943
+ // NOTE(nicksantos): Sometimes, evaluating document.activeElement in IE
1944
+ // throws an exception. I'm not 100% sure why, but I suspect it chokes
1945
+ // on document.activeElement if the activeElement has been recently
1946
+ // removed from the DOM by a JS operation.
1947
+ //
1948
+ // We assume that an exception here simply means
1949
+ // "there is no active element."
1950
+ }
1951
+
1952
+ return null;
1953
+ };
1954
+
1955
+
1956
+
1957
+ /**
1958
+ * Create an instance of a DOM helper with a new document object.
1959
+ * @param {Document=} opt_document Document object to associate with this
1960
+ * DOM helper.
1961
+ * @constructor
1962
+ */
1963
+ goog.dom.DomHelper = function(opt_document) {
1964
+ /**
1965
+ * Reference to the document object to use
1966
+ * @type {!Document}
1967
+ * @private
1968
+ */
1969
+ this.document_ = opt_document || goog.global.document || document;
1970
+ };
1971
+
1972
+
1973
+ /**
1974
+ * Gets the dom helper object for the document where the element resides.
1975
+ * @param {Node=} opt_node If present, gets the DomHelper for this node.
1976
+ * @return {!goog.dom.DomHelper} The DomHelper.
1977
+ */
1978
+ goog.dom.DomHelper.prototype.getDomHelper = goog.dom.getDomHelper;
1979
+
1980
+
1981
+ /**
1982
+ * Sets the document object.
1983
+ * @param {!Document} document Document object.
1984
+ */
1985
+ goog.dom.DomHelper.prototype.setDocument = function(document) {
1986
+ this.document_ = document;
1987
+ };
1988
+
1989
+
1990
+ /**
1991
+ * Gets the document object being used by the dom library.
1992
+ * @return {!Document} Document object.
1993
+ */
1994
+ goog.dom.DomHelper.prototype.getDocument = function() {
1995
+ return this.document_;
1996
+ };
1997
+
1998
+
1999
+ /**
2000
+ * Alias for {@code getElementById}. If a DOM node is passed in then we just
2001
+ * return that.
2002
+ * @param {string|Element} element Element ID or a DOM node.
2003
+ * @return {Element} The element with the given ID, or the node passed in.
2004
+ */
2005
+ goog.dom.DomHelper.prototype.getElement = function(element) {
2006
+ if (goog.isString(element)) {
2007
+ return this.document_.getElementById(element);
2008
+ } else {
2009
+ return element;
2010
+ }
2011
+ };
2012
+
2013
+
2014
+ /**
2015
+ * Alias for {@code getElement}.
2016
+ * @param {string|Element} element Element ID or a DOM node.
2017
+ * @return {Element} The element with the given ID, or the node passed in.
2018
+ * @deprecated Use {@link goog.dom.DomHelper.prototype.getElement} instead.
2019
+ */
2020
+ goog.dom.DomHelper.prototype.$ = goog.dom.DomHelper.prototype.getElement;
2021
+
2022
+
2023
+ /**
2024
+ * Looks up elements by both tag and class name, using browser native functions
2025
+ * ({@code querySelectorAll}, {@code getElementsByTagName} or
2026
+ * {@code getElementsByClassName}) where possible. The returned array is a live
2027
+ * NodeList or a static list depending on the code path taken.
2028
+ *
2029
+ * @see goog.dom.query
2030
+ *
2031
+ * @param {?string=} opt_tag Element tag name or * for all tags.
2032
+ * @param {?string=} opt_class Optional class name.
2033
+ * @param {Document|Element=} opt_el Optional element to look in.
2034
+ * @return { {length: number} } Array-like list of elements (only a length
2035
+ * property and numerical indices are guaranteed to exist).
2036
+ */
2037
+ goog.dom.DomHelper.prototype.getElementsByTagNameAndClass = function(opt_tag,
2038
+ opt_class,
2039
+ opt_el) {
2040
+ return goog.dom.getElementsByTagNameAndClass_(this.document_, opt_tag,
2041
+ opt_class, opt_el);
2042
+ };
2043
+
2044
+
2045
+ /**
2046
+ * Returns an array of all the elements with the provided className.
2047
+ * @see {goog.dom.query}
2048
+ * @param {string} className the name of the class to look for.
2049
+ * @param {Element|Document=} opt_el Optional element to look in.
2050
+ * @return { {length: number} } The items found with the class name provided.
2051
+ */
2052
+ goog.dom.DomHelper.prototype.getElementsByClass = function(className, opt_el) {
2053
+ var doc = opt_el || this.document_;
2054
+ return goog.dom.getElementsByClass(className, doc);
2055
+ };
2056
+
2057
+
2058
+ /**
2059
+ * Returns the first element we find matching the provided class name.
2060
+ * @see {goog.dom.query}
2061
+ * @param {string} className the name of the class to look for.
2062
+ * @param {Element|Document=} opt_el Optional element to look in.
2063
+ * @return {Element} The first item found with the class name provided.
2064
+ */
2065
+ goog.dom.DomHelper.prototype.getElementByClass = function(className, opt_el) {
2066
+ var doc = opt_el || this.document_;
2067
+ return goog.dom.getElementByClass(className, doc);
2068
+ };
2069
+
2070
+
2071
+ /**
2072
+ * Alias for {@code getElementsByTagNameAndClass}.
2073
+ * @deprecated Use DomHelper getElementsByTagNameAndClass.
2074
+ * @see goog.dom.query
2075
+ *
2076
+ * @param {?string=} opt_tag Element tag name.
2077
+ * @param {?string=} opt_class Optional class name.
2078
+ * @param {Element=} opt_el Optional element to look in.
2079
+ * @return { {length: number} } Array-like list of elements (only a length
2080
+ * property and numerical indices are guaranteed to exist).
2081
+ */
2082
+ goog.dom.DomHelper.prototype.$$ =
2083
+ goog.dom.DomHelper.prototype.getElementsByTagNameAndClass;
2084
+
2085
+
2086
+ /**
2087
+ * Sets a number of properties on a node.
2088
+ * @param {Element} element DOM node to set properties on.
2089
+ * @param {Object} properties Hash of property:value pairs.
2090
+ */
2091
+ goog.dom.DomHelper.prototype.setProperties = goog.dom.setProperties;
2092
+
2093
+
2094
+ /**
2095
+ * Gets the dimensions of the viewport.
2096
+ * @param {Window=} opt_window Optional window element to test. Defaults to
2097
+ * the window of the Dom Helper.
2098
+ * @return {!goog.math.Size} Object with values 'width' and 'height'.
2099
+ */
2100
+ goog.dom.DomHelper.prototype.getViewportSize = function(opt_window) {
2101
+ // TODO(arv): This should not take an argument. That breaks the rule of a
2102
+ // a DomHelper representing a single frame/window/document.
2103
+ return goog.dom.getViewportSize(opt_window || this.getWindow());
2104
+ };
2105
+
2106
+
2107
+ /**
2108
+ * Calculates the height of the document.
2109
+ *
2110
+ * @return {number} The height of the document.
2111
+ */
2112
+ goog.dom.DomHelper.prototype.getDocumentHeight = function() {
2113
+ return goog.dom.getDocumentHeight_(this.getWindow());
2114
+ };
2115
+
2116
+
2117
+ /**
2118
+ * Typedef for use with goog.dom.createDom and goog.dom.append.
2119
+ * @typedef {Object|string|Array|NodeList}
2120
+ */
2121
+ goog.dom.Appendable;
2122
+
2123
+
2124
+ /**
2125
+ * Returns a dom node with a set of attributes. This function accepts varargs
2126
+ * for subsequent nodes to be added. Subsequent nodes will be added to the
2127
+ * first node as childNodes.
2128
+ *
2129
+ * So:
2130
+ * <code>createDom('div', null, createDom('p'), createDom('p'));</code>
2131
+ * would return a div with two child paragraphs
2132
+ *
2133
+ * An easy way to move all child nodes of an existing element to a new parent
2134
+ * element is:
2135
+ * <code>createDom('div', null, oldElement.childNodes);</code>
2136
+ * which will remove all child nodes from the old element and add them as
2137
+ * child nodes of the new DIV.
2138
+ *
2139
+ * @param {string} tagName Tag to create.
2140
+ * @param {Object|string=} opt_attributes If object, then a map of name-value
2141
+ * pairs for attributes. If a string, then this is the className of the new
2142
+ * element.
2143
+ * @param {...goog.dom.Appendable} var_args Further DOM nodes or
2144
+ * strings for text nodes. If one of the var_args is an array or
2145
+ * NodeList, its elements will be added as childNodes instead.
2146
+ * @return {!Element} Reference to a DOM node.
2147
+ */
2148
+ goog.dom.DomHelper.prototype.createDom = function(tagName,
2149
+ opt_attributes,
2150
+ var_args) {
2151
+ return goog.dom.createDom_(this.document_, arguments);
2152
+ };
2153
+
2154
+
2155
+ /**
2156
+ * Alias for {@code createDom}.
2157
+ * @param {string} tagName Tag to create.
2158
+ * @param {Object|string=} opt_attributes If object, then a map of name-value
2159
+ * pairs for attributes. If a string, then this is the className of the new
2160
+ * element.
2161
+ * @param {...goog.dom.Appendable} var_args Further DOM nodes or strings for
2162
+ * text nodes. If one of the var_args is an array, its children will be
2163
+ * added as childNodes instead.
2164
+ * @return {!Element} Reference to a DOM node.
2165
+ * @deprecated Use {@link goog.dom.DomHelper.prototype.createDom} instead.
2166
+ */
2167
+ goog.dom.DomHelper.prototype.$dom = goog.dom.DomHelper.prototype.createDom;
2168
+
2169
+
2170
+ /**
2171
+ * Creates a new element.
2172
+ * @param {string} name Tag name.
2173
+ * @return {!Element} The new element.
2174
+ */
2175
+ goog.dom.DomHelper.prototype.createElement = function(name) {
2176
+ return this.document_.createElement(name);
2177
+ };
2178
+
2179
+
2180
+ /**
2181
+ * Creates a new text node.
2182
+ * @param {string} content Content.
2183
+ * @return {!Text} The new text node.
2184
+ */
2185
+ goog.dom.DomHelper.prototype.createTextNode = function(content) {
2186
+ return this.document_.createTextNode(content);
2187
+ };
2188
+
2189
+
2190
+ /**
2191
+ * Create a table.
2192
+ * @param {number} rows The number of rows in the table. Must be >= 1.
2193
+ * @param {number} columns The number of columns in the table. Must be >= 1.
2194
+ * @param {boolean=} opt_fillWithNbsp If true, fills table entries with nsbps.
2195
+ * @return {!Element} The created table.
2196
+ */
2197
+ goog.dom.DomHelper.prototype.createTable = function(rows, columns,
2198
+ opt_fillWithNbsp) {
2199
+ return goog.dom.createTable_(this.document_, rows, columns,
2200
+ !!opt_fillWithNbsp);
2201
+ };
2202
+
2203
+
2204
+ /**
2205
+ * Converts an HTML string into a node or a document fragment. A single Node
2206
+ * is used if the {@code htmlString} only generates a single node. If the
2207
+ * {@code htmlString} generates multiple nodes then these are put inside a
2208
+ * {@code DocumentFragment}.
2209
+ *
2210
+ * @param {string} htmlString The HTML string to convert.
2211
+ * @return {!Node} The resulting node.
2212
+ */
2213
+ goog.dom.DomHelper.prototype.htmlToDocumentFragment = function(htmlString) {
2214
+ return goog.dom.htmlToDocumentFragment_(this.document_, htmlString);
2215
+ };
2216
+
2217
+
2218
+ /**
2219
+ * Returns the compatMode of the document.
2220
+ * @return {string} The result is either CSS1Compat or BackCompat.
2221
+ * @deprecated use goog.dom.DomHelper.prototype.isCss1CompatMode instead.
2222
+ */
2223
+ goog.dom.DomHelper.prototype.getCompatMode = function() {
2224
+ return this.isCss1CompatMode() ? 'CSS1Compat' : 'BackCompat';
2225
+ };
2226
+
2227
+
2228
+ /**
2229
+ * Returns true if the browser is in "CSS1-compatible" (standards-compliant)
2230
+ * mode, false otherwise.
2231
+ * @return {boolean} True if in CSS1-compatible mode.
2232
+ */
2233
+ goog.dom.DomHelper.prototype.isCss1CompatMode = function() {
2234
+ return goog.dom.isCss1CompatMode_(this.document_);
2235
+ };
2236
+
2237
+
2238
+ /**
2239
+ * Gets the window object associated with the document.
2240
+ * @return {!Window} The window associated with the given document.
2241
+ */
2242
+ goog.dom.DomHelper.prototype.getWindow = function() {
2243
+ return goog.dom.getWindow_(this.document_);
2244
+ };
2245
+
2246
+
2247
+ /**
2248
+ * Gets the document scroll element.
2249
+ * @return {Element} Scrolling element.
2250
+ */
2251
+ goog.dom.DomHelper.prototype.getDocumentScrollElement = function() {
2252
+ return goog.dom.getDocumentScrollElement_(this.document_);
2253
+ };
2254
+
2255
+
2256
+ /**
2257
+ * Gets the document scroll distance as a coordinate object.
2258
+ * @return {!goog.math.Coordinate} Object with properties 'x' and 'y'.
2259
+ */
2260
+ goog.dom.DomHelper.prototype.getDocumentScroll = function() {
2261
+ return goog.dom.getDocumentScroll_(this.document_);
2262
+ };
2263
+
2264
+
2265
+ /**
2266
+ * Appends a child to a node.
2267
+ * @param {Node} parent Parent.
2268
+ * @param {Node} child Child.
2269
+ */
2270
+ goog.dom.DomHelper.prototype.appendChild = goog.dom.appendChild;
2271
+
2272
+
2273
+ /**
2274
+ * Appends a node with text or other nodes.
2275
+ * @param {!Node} parent The node to append nodes to.
2276
+ * @param {...goog.dom.Appendable} var_args The things to append to the node.
2277
+ * If this is a Node it is appended as is.
2278
+ * If this is a string then a text node is appended.
2279
+ * If this is an array like object then fields 0 to length - 1 are appended.
2280
+ */
2281
+ goog.dom.DomHelper.prototype.append = goog.dom.append;
2282
+
2283
+
2284
+ /**
2285
+ * Removes all the child nodes on a DOM node.
2286
+ * @param {Node} node Node to remove children from.
2287
+ */
2288
+ goog.dom.DomHelper.prototype.removeChildren = goog.dom.removeChildren;
2289
+
2290
+
2291
+ /**
2292
+ * Inserts a new node before an existing reference node (i.e., as the previous
2293
+ * sibling). If the reference node has no parent, then does nothing.
2294
+ * @param {Node} newNode Node to insert.
2295
+ * @param {Node} refNode Reference node to insert before.
2296
+ */
2297
+ goog.dom.DomHelper.prototype.insertSiblingBefore = goog.dom.insertSiblingBefore;
2298
+
2299
+
2300
+ /**
2301
+ * Inserts a new node after an existing reference node (i.e., as the next
2302
+ * sibling). If the reference node has no parent, then does nothing.
2303
+ * @param {Node} newNode Node to insert.
2304
+ * @param {Node} refNode Reference node to insert after.
2305
+ */
2306
+ goog.dom.DomHelper.prototype.insertSiblingAfter = goog.dom.insertSiblingAfter;
2307
+
2308
+
2309
+ /**
2310
+ * Removes a node from its parent.
2311
+ * @param {Node} node The node to remove.
2312
+ * @return {Node} The node removed if removed; else, null.
2313
+ */
2314
+ goog.dom.DomHelper.prototype.removeNode = goog.dom.removeNode;
2315
+
2316
+
2317
+ /**
2318
+ * Replaces a node in the DOM tree. Will do nothing if {@code oldNode} has no
2319
+ * parent.
2320
+ * @param {Node} newNode Node to insert.
2321
+ * @param {Node} oldNode Node to replace.
2322
+ */
2323
+ goog.dom.DomHelper.prototype.replaceNode = goog.dom.replaceNode;
2324
+
2325
+
2326
+ /**
2327
+ * Flattens an element. That is, removes it and replace it with its children.
2328
+ * @param {Element} element The element to flatten.
2329
+ * @return {Element|undefined} The original element, detached from the document
2330
+ * tree, sans children, or undefined if the element was already not in the
2331
+ * document.
2332
+ */
2333
+ goog.dom.DomHelper.prototype.flattenElement = goog.dom.flattenElement;
2334
+
2335
+
2336
+ /**
2337
+ * Returns the first child node that is an element.
2338
+ * @param {Node} node The node to get the first child element of.
2339
+ * @return {Element} The first child node of {@code node} that is an element.
2340
+ */
2341
+ goog.dom.DomHelper.prototype.getFirstElementChild =
2342
+ goog.dom.getFirstElementChild;
2343
+
2344
+
2345
+ /**
2346
+ * Returns the last child node that is an element.
2347
+ * @param {Node} node The node to get the last child element of.
2348
+ * @return {Element} The last child node of {@code node} that is an element.
2349
+ */
2350
+ goog.dom.DomHelper.prototype.getLastElementChild = goog.dom.getLastElementChild;
2351
+
2352
+
2353
+ /**
2354
+ * Returns the first next sibling that is an element.
2355
+ * @param {Node} node The node to get the next sibling element of.
2356
+ * @return {Element} The next sibling of {@code node} that is an element.
2357
+ */
2358
+ goog.dom.DomHelper.prototype.getNextElementSibling =
2359
+ goog.dom.getNextElementSibling;
2360
+
2361
+
2362
+ /**
2363
+ * Returns the first previous sibling that is an element.
2364
+ * @param {Node} node The node to get the previous sibling element of.
2365
+ * @return {Element} The first previous sibling of {@code node} that is
2366
+ * an element.
2367
+ */
2368
+ goog.dom.DomHelper.prototype.getPreviousElementSibling =
2369
+ goog.dom.getPreviousElementSibling;
2370
+
2371
+
2372
+ /**
2373
+ * Returns the next node in source order from the given node.
2374
+ * @param {Node} node The node.
2375
+ * @return {Node} The next node in the DOM tree, or null if this was the last
2376
+ * node.
2377
+ */
2378
+ goog.dom.DomHelper.prototype.getNextNode =
2379
+ goog.dom.getNextNode;
2380
+
2381
+
2382
+ /**
2383
+ * Returns the previous node in source order from the given node.
2384
+ * @param {Node} node The node.
2385
+ * @return {Node} The previous node in the DOM tree, or null if this was the
2386
+ * first node.
2387
+ */
2388
+ goog.dom.DomHelper.prototype.getPreviousNode =
2389
+ goog.dom.getPreviousNode;
2390
+
2391
+
2392
+ /**
2393
+ * Whether the object looks like a DOM node.
2394
+ * @param {*} obj The object being tested for node likeness.
2395
+ * @return {boolean} Whether the object looks like a DOM node.
2396
+ */
2397
+ goog.dom.DomHelper.prototype.isNodeLike = goog.dom.isNodeLike;
2398
+
2399
+
2400
+ /**
2401
+ * Whether a node contains another node.
2402
+ * @param {Node} parent The node that should contain the other node.
2403
+ * @param {Node} descendant The node to test presence of.
2404
+ * @return {boolean} Whether the parent node contains the descendent node.
2405
+ */
2406
+ goog.dom.DomHelper.prototype.contains = goog.dom.contains;
2407
+
2408
+
2409
+ /**
2410
+ * Returns the owner document for a node.
2411
+ * @param {Node} node The node to get the document for.
2412
+ * @return {!Document} The document owning the node.
2413
+ */
2414
+ goog.dom.DomHelper.prototype.getOwnerDocument = goog.dom.getOwnerDocument;
2415
+
2416
+
2417
+ /**
2418
+ * Cross browser function for getting the document element of an iframe.
2419
+ * @param {HTMLIFrameElement|HTMLFrameElement} iframe Iframe element.
2420
+ * @return {!HTMLDocument} The frame content document.
2421
+ */
2422
+ goog.dom.DomHelper.prototype.getFrameContentDocument =
2423
+ goog.dom.getFrameContentDocument;
2424
+
2425
+
2426
+ /**
2427
+ * Cross browser function for getting the window of a frame or iframe.
2428
+ * @param {HTMLIFrameElement|HTMLFrameElement} frame Frame element.
2429
+ * @return {Window} The window associated with the given frame.
2430
+ */
2431
+ goog.dom.DomHelper.prototype.getFrameContentWindow =
2432
+ goog.dom.getFrameContentWindow;
2433
+
2434
+
2435
+ /**
2436
+ * Cross browser function for setting the text content of an element.
2437
+ * @param {Element} element The element to change the text content of.
2438
+ * @param {string} text The string that should replace the current element
2439
+ * content with.
2440
+ */
2441
+ goog.dom.DomHelper.prototype.setTextContent = goog.dom.setTextContent;
2442
+
2443
+
2444
+ /**
2445
+ * Finds the first descendant node that matches the filter function. This does
2446
+ * a depth first search.
2447
+ * @param {Node} root The root of the tree to search.
2448
+ * @param {function(Node) : boolean} p The filter function.
2449
+ * @return {(Node, undefined)} The found node or undefined if none is found.
2450
+ */
2451
+ goog.dom.DomHelper.prototype.findNode = goog.dom.findNode;
2452
+
2453
+
2454
+ /**
2455
+ * Finds all the descendant nodes that matches the filter function. This does a
2456
+ * depth first search.
2457
+ * @param {Node} root The root of the tree to search.
2458
+ * @param {function(Node) : boolean} p The filter function.
2459
+ * @return {Array.<Node>} The found nodes or an empty array if none are found.
2460
+ */
2461
+ goog.dom.DomHelper.prototype.findNodes = goog.dom.findNodes;
2462
+
2463
+
2464
+ /**
2465
+ * Returns the text contents of the current node, without markup. New lines are
2466
+ * stripped and whitespace is collapsed, such that each character would be
2467
+ * visible.
2468
+ *
2469
+ * In browsers that support it, innerText is used. Other browsers attempt to
2470
+ * simulate it via node traversal. Line breaks are canonicalized in IE.
2471
+ *
2472
+ * @param {Node} node The node from which we are getting content.
2473
+ * @return {string} The text content.
2474
+ */
2475
+ goog.dom.DomHelper.prototype.getTextContent = goog.dom.getTextContent;
2476
+
2477
+
2478
+ /**
2479
+ * Returns the text length of the text contained in a node, without markup. This
2480
+ * is equivalent to the selection length if the node was selected, or the number
2481
+ * of cursor movements to traverse the node. Images & BRs take one space. New
2482
+ * lines are ignored.
2483
+ *
2484
+ * @param {Node} node The node whose text content length is being calculated.
2485
+ * @return {number} The length of {@code node}'s text content.
2486
+ */
2487
+ goog.dom.DomHelper.prototype.getNodeTextLength = goog.dom.getNodeTextLength;
2488
+
2489
+
2490
+ /**
2491
+ * Returns the text offset of a node relative to one of its ancestors. The text
2492
+ * length is the same as the length calculated by
2493
+ * {@code goog.dom.getNodeTextLength}.
2494
+ *
2495
+ * @param {Node} node The node whose offset is being calculated.
2496
+ * @param {Node=} opt_offsetParent Defaults to the node's owner document's body.
2497
+ * @return {number} The text offset.
2498
+ */
2499
+ goog.dom.DomHelper.prototype.getNodeTextOffset = goog.dom.getNodeTextOffset;
2500
+
2501
+
2502
+ /**
2503
+ * Walks up the DOM hierarchy returning the first ancestor that has the passed
2504
+ * tag name and/or class name. If the passed element matches the specified
2505
+ * criteria, the element itself is returned.
2506
+ * @param {Node} element The DOM node to start with.
2507
+ * @param {?string=} opt_tag The tag name to match (or null/undefined to match
2508
+ * any node regardless of tag name). Must be uppercase (goog.dom.TagName).
2509
+ * @param {?string=} opt_class The class name to match (or null/undefined to
2510
+ * match any node regardless of class name).
2511
+ * @return {Node} The first ancestor that matches the passed criteria, or
2512
+ * null if none match.
2513
+ */
2514
+ goog.dom.DomHelper.prototype.getAncestorByTagNameAndClass =
2515
+ goog.dom.getAncestorByTagNameAndClass;
2516
+
2517
+
2518
+ /**
2519
+ * Walks up the DOM hierarchy returning the first ancestor that has the passed
2520
+ * class name. If the passed element matches the specified criteria, the
2521
+ * element itself is returned.
2522
+ * @param {Node} element The DOM node to start with.
2523
+ * @param {?string=} opt_class The class name to match (or null/undefined to
2524
+ * match any node regardless of class name).
2525
+ * @return {Node} The first ancestor that matches the passed criteria, or
2526
+ * null if none match.
2527
+ */
2528
+ goog.dom.DomHelper.prototype.getAncestorByClass =
2529
+ goog.dom.getAncestorByClass;
2530
+
2531
+
2532
+ /**
2533
+ * Walks up the DOM hierarchy returning the first ancestor that passes the
2534
+ * matcher function.
2535
+ * @param {Node} element The DOM node to start with.
2536
+ * @param {function(Node) : boolean} matcher A function that returns true if the
2537
+ * passed node matches the desired criteria.
2538
+ * @param {boolean=} opt_includeNode If true, the node itself is included in
2539
+ * the search (the first call to the matcher will pass startElement as
2540
+ * the node to test).
2541
+ * @param {number=} opt_maxSearchSteps Maximum number of levels to search up the
2542
+ * dom.
2543
+ * @return {Node} DOM node that matched the matcher, or null if there was
2544
+ * no match.
2545
+ */
2546
+ goog.dom.DomHelper.prototype.getAncestor = goog.dom.getAncestor;
2547
+ ;
2548
+ FI"asset_paths;
2549
+ F["b/Volumes/Development/dev-web/yellow-brick-road/vendor/closure-library/closure/goog/dom/dom.jsI"dependency_paths;
2550
+ F[{I" path;
2551
+ F"b/Volumes/Development/dev-web/yellow-brick-road/vendor/closure-library/closure/goog/dom/dom.jsI"
2552
+ mtime;
2553
+ FIu: Time
2554
+ T: offsetiI"hexdigest;
2555
+ F"%727ecd3542acdd7f6cf9417a0cd1b810I"
2556
+ F"%46dde6621c301f4928e3b34efee9e3b5