lib/goog/dom/browserfeature.js

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/**
16 * @fileoverview Browser capability checks for the dom package.
17 *
18 */
19
20
21goog.provide('goog.dom.BrowserFeature');
22
23goog.require('goog.userAgent');
24
25
26/**
27 * Enum of browser capabilities.
28 * @enum {boolean}
29 */
30goog.dom.BrowserFeature = {
31 /**
32 * Whether attributes 'name' and 'type' can be added to an element after it's
33 * created. False in Internet Explorer prior to version 9.
34 */
35 CAN_ADD_NAME_OR_TYPE_ATTRIBUTES: !goog.userAgent.IE ||
36 goog.userAgent.isDocumentModeOrHigher(9),
37
38 /**
39 * Whether we can use element.children to access an element's Element
40 * children. Available since Gecko 1.9.1, IE 9. (IE<9 also includes comment
41 * nodes in the collection.)
42 */
43 CAN_USE_CHILDREN_ATTRIBUTE: !goog.userAgent.GECKO && !goog.userAgent.IE ||
44 goog.userAgent.IE && goog.userAgent.isDocumentModeOrHigher(9) ||
45 goog.userAgent.GECKO && goog.userAgent.isVersionOrHigher('1.9.1'),
46
47 /**
48 * Opera, Safari 3, and Internet Explorer 9 all support innerText but they
49 * include text nodes in script and style tags. Not document-mode-dependent.
50 */
51 CAN_USE_INNER_TEXT: (
52 goog.userAgent.IE && !goog.userAgent.isVersionOrHigher('9')),
53
54 /**
55 * MSIE, Opera, and Safari>=4 support element.parentElement to access an
56 * element's parent if it is an Element.
57 */
58 CAN_USE_PARENT_ELEMENT_PROPERTY: goog.userAgent.IE || goog.userAgent.OPERA ||
59 goog.userAgent.WEBKIT,
60
61 /**
62 * Whether NoScope elements need a scoped element written before them in
63 * innerHTML.
64 * MSDN: http://msdn.microsoft.com/en-us/library/ms533897(VS.85).aspx#1
65 */
66 INNER_HTML_NEEDS_SCOPED_ELEMENT: goog.userAgent.IE,
67
68 /**
69 * Whether we use legacy IE range API.
70 */
71 LEGACY_IE_RANGES: goog.userAgent.IE && !goog.userAgent.isDocumentModeOrHigher(9)
72};