Debian Codegraph @

closure-library/closure/goog/dom/dom_compile_test.js

raw
1 // Copyright 2016 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 goog.provide('goog.dom.DomCompileTest');
16 goog.setTestOnly();
17
18
19 goog.require('goog.dom');
20 goog.require('goog.dom.TagName');
21 goog.require('goog.testing.jsunit');
22
23
24 /** Checks types with goog.dom.TagName. */
25 function testDomTagNameTypes() {
26 /** @type {!HTMLAnchorElement} */
27 var a = goog.dom.createDom(goog.dom.TagName.A);
28
29 /** @type {!HTMLAnchorElement} */
30 var el = goog.dom.createElement(goog.dom.TagName.A);
31
32 /** @type {!IArrayLike<!HTMLAnchorElement>} */
33 var anchors = goog.dom.getElementsByTagNameAndClass(goog.dom.TagName.A);
34
35 // Check that goog.dom.HtmlElement is assignable to HTMLElement.
36 /** @type {!HTMLElement} */
37 var b = goog.dom.createElement(goog.dom.TagName.B);
38
39 /** @type {?HTMLAnchorElement} */
40 var anchor = goog.dom.getElementByTagNameAndClass(goog.dom.TagName.A);
41 }
42
43
44 /** Checks types with goog.dom.TagName. */
45 function testDomHelperTagNameTypes() {
46 var dom = goog.dom.getDomHelper();
47
48 /** @type {!HTMLAnchorElement} */
49 var a = dom.createDom(goog.dom.TagName.A);
50
51 /** @type {!HTMLAnchorElement} */
52 var el = dom.createElement(goog.dom.TagName.A);
53
54 /** @type {!IArrayLike<!HTMLAnchorElement>} */
55 var anchors = dom.getElementsByTagNameAndClass(goog.dom.TagName.A);
56
57 /** @type {?HTMLAnchorElement} */
58 var anchor = dom.getElementByTagNameAndClass(goog.dom.TagName.A);
59 }