1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * Creates an element named |elementName| containing the content |text|.
7 * @param {string} elementName Name of the new element to be created.
8 * @param {string} text Text to be contained in the new element.
9 * @param {Object} opt_attributes Optional attribute dictionary for the element.
10 * @return {HTMLElement} The newly created HTML element.
12 function createElementFromText(elementName
, text
, opt_attributes
) {
13 var element
= document
.createElement(elementName
);
14 element
.appendChild(document
.createTextNode(text
));
16 for (var key
in opt_attributes
)
17 element
.setAttribute(key
, opt_attributes
[key
]);
23 * Creates an element with |tagName| containing the content |dict|.
24 * @param {string} elementName Name of the new element to be created.
25 * @param {Object<string>} dict Dictionary to be contained in the new
27 * @return {HTMLElement} The newly created HTML element.
29 function createElementFromDictionary(elementName
, dict
) {
30 var element
= document
.createElement(elementName
);
31 for (var key
in dict
) {
32 element
.appendChild(document
.createTextNode(key
+ ': ' + dict
[key
]));
33 element
.appendChild(document
.createElement('br'));