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 */
18goog.provide('goog.dom.tags');
19
20goog.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
27 * @type {!Object}
28 * @private
29 */
30goog.dom.tags.VOID_TAGS_ = goog.object.createSet(('area,base,br,col,command,' +
31 'embed,hr,img,input,keygen,link,meta,param,source,track,wbr').split(','));
32
33
34/**
35 * Checks whether the tag is void (with no contents allowed and no legal end
36 * tag), for example 'br'.
37 * @param {string} tagName The tag name in lower case.
38 * @return {boolean}
39 */
40goog.dom.tags.isVoidTag = function(tagName) {
41 return goog.dom.tags.VOID_TAGS_[tagName] === true;
42};