# lib/goog/dom/tags.js

1 | // Copyright 2014 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 Utilities for HTML element tag names.
17 | */
18 | goog.provide('goog.dom.tags');
19 |
20 | goog.require('goog.object');
21 |
22 |
23 | /**
24 | * The void elements specified by
25 | * http://www.w3.org/TR/html-markup/syntax.html#void-elements.
26 | * @const @private {!Object<string, boolean>}
27 | */
28 | goog.dom.tags.VOID_TAGS_ = goog.object.createSet(
29 | 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input',
30 | 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr');
31 |
32 |
33 | /**
34 | * Checks whether the tag is void (with no contents allowed and no legal end
35 | * tag), for example 'br'.
36 | * @param {string} tagName The tag name in lower case.
37 | * @return {boolean}
38 | */
39 | goog.dom.tags.isVoidTag = function(tagName) {
40 | return goog.dom.tags.VOID_TAGS_[tagName] === true;
41 | };