dom_compile_test.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. goog.setTestOnly();
  15. goog.require('goog.dom');
  16. goog.require('goog.dom.TagName');
  17. goog.require('goog.testing.jsunit');
  18. /** Checks types with goog.dom.TagName. */
  19. function testDomTagNameTypes() {
  20. /** @type {!HTMLAnchorElement} */
  21. var a = goog.dom.createDom(goog.dom.TagName.A);
  22. /** @type {!HTMLAnchorElement} */
  23. var el = goog.dom.createElement(goog.dom.TagName.A);
  24. /** @type {!IArrayLike<!HTMLAnchorElement>} */
  25. var anchors = goog.dom.getElementsByTagNameAndClass(goog.dom.TagName.A);
  26. // Check that goog.dom.HtmlElement is assignable to HTMLElement.
  27. /** @type {!HTMLElement} */
  28. var b = goog.dom.createElement(goog.dom.TagName.B);
  29. /** @type {?HTMLAnchorElement} */
  30. var anchor = goog.dom.getElementByTagNameAndClass(goog.dom.TagName.A);
  31. }
  32. /** Checks types with goog.dom.TagName. */
  33. function testDomHelperTagNameTypes() {
  34. var dom = goog.dom.getDomHelper();
  35. /** @type {!HTMLAnchorElement} */
  36. var a = dom.createDom(goog.dom.TagName.A);
  37. /** @type {!HTMLAnchorElement} */
  38. var el = dom.createElement(goog.dom.TagName.A);
  39. /** @type {!IArrayLike<!HTMLAnchorElement>} */
  40. var anchors = dom.getElementsByTagNameAndClass(goog.dom.TagName.A);
  41. /** @type {?HTMLAnchorElement} */
  42. var anchor = dom.getElementByTagNameAndClass(goog.dom.TagName.A);
  43. }