browserfeature.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2010 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @fileoverview Browser capability checks for the dom package.
  16. *
  17. */
  18. goog.provide('goog.dom.BrowserFeature');
  19. goog.require('goog.userAgent');
  20. /**
  21. * Enum of browser capabilities.
  22. * @enum {boolean}
  23. */
  24. goog.dom.BrowserFeature = {
  25. /**
  26. * Whether attributes 'name' and 'type' can be added to an element after it's
  27. * created. False in Internet Explorer prior to version 9.
  28. */
  29. CAN_ADD_NAME_OR_TYPE_ATTRIBUTES:
  30. !goog.userAgent.IE || goog.userAgent.isDocumentModeOrHigher(9),
  31. /**
  32. * Whether we can use element.children to access an element's Element
  33. * children. Available since Gecko 1.9.1, IE 9. (IE<9 also includes comment
  34. * nodes in the collection.)
  35. */
  36. CAN_USE_CHILDREN_ATTRIBUTE: !goog.userAgent.GECKO && !goog.userAgent.IE ||
  37. goog.userAgent.IE && goog.userAgent.isDocumentModeOrHigher(9) ||
  38. goog.userAgent.GECKO && goog.userAgent.isVersionOrHigher('1.9.1'),
  39. /**
  40. * Opera, Safari 3, and Internet Explorer 9 all support innerText but they
  41. * include text nodes in script and style tags. Not document-mode-dependent.
  42. */
  43. CAN_USE_INNER_TEXT:
  44. (goog.userAgent.IE && !goog.userAgent.isVersionOrHigher('9')),
  45. /**
  46. * MSIE, Opera, and Safari>=4 support element.parentElement to access an
  47. * element's parent if it is an Element.
  48. */
  49. CAN_USE_PARENT_ELEMENT_PROPERTY:
  50. goog.userAgent.IE || goog.userAgent.OPERA || goog.userAgent.WEBKIT,
  51. /**
  52. * Whether NoScope elements need a scoped element written before them in
  53. * innerHTML.
  54. * MSDN: http://msdn.microsoft.com/en-us/library/ms533897(VS.85).aspx#1
  55. */
  56. INNER_HTML_NEEDS_SCOPED_ELEMENT: goog.userAgent.IE,
  57. /**
  58. * Whether we use legacy IE range API.
  59. */
  60. LEGACY_IE_RANGES:
  61. goog.userAgent.IE && !goog.userAgent.isDocumentModeOrHigher(9)
  62. };