|
24 | 24 | return e === element.ownerDocument;
|
25 | 25 | }
|
26 | 26 |
|
27 |
| - function openTag(tagName, attrs) { |
| 27 | + function htmlTag(tagName, attrs) { |
| 28 | + var content = Array.prototype.slice.call(arguments, 2); |
| 29 | + if (typeof attrs !== 'object') { |
| 30 | + content.unshift(attrs); |
| 31 | + attrs = null; |
| 32 | + } |
| 33 | + |
28 | 34 | var html = '<' + tagName;
|
29 | 35 | for (var key in attrs) {
|
30 | 36 | var value = attrs[key];
|
|
36 | 42 | html += " " + key.escapeHtml() + '="' + value.toString().escapeHtml() + '"';
|
37 | 43 | }
|
38 | 44 | }
|
39 |
| - html += '>'; |
40 |
| - return html; |
41 |
| - } |
42 |
| - function closeTag(tagName) { |
43 |
| - return '</' + tagName + '>'; |
| 45 | + return html += '>' + content.join('') + '</' + tagName + '>'; |
44 | 46 | }
|
45 |
| - |
| 47 | + api.util.tag = htmlTag; |
| 48 | + |
46 | 49 | var specialAttributes = {
|
47 | 50 | 'class': function (element, value) {
|
48 | 51 | if (value === null) {
|
|
676 | 679 | var context = thisContext._subContext(model, binding, uiPath);
|
677 | 680 | context._renderInnerHtml(model, binding, tag, attrs, function (error, html) {
|
678 | 681 | if (typeof html === 'string') {
|
679 |
| - html = openTag(tag, attrs) + html + closeTag(tag); |
| 682 | + html = htmlTag(tag, attrs, html) |
680 | 683 | }
|
681 | 684 | callback(error, html);
|
682 | 685 | });
|
|
703 | 706 | if (!rootModel) {
|
704 | 707 | var error = new Error('Missing from data store: ' + data.key);
|
705 | 708 | var errorHtml = thisContext.errorHtml(error, data.tag, data.attrs)
|
706 |
| - return callback(error, openTag(data.tag, data.attrs) + errorHtml + closeTag(data.tag, data.attrs)); |
| 709 | + return callback(error, htmlTag(data.tag, data.attrs, errorHtml)); |
707 | 710 | }
|
708 | 711 | var model = rootModel.modelForPath(data.path);
|
709 | 712 | if (thisContext.includeDataProperties) {
|
|
742 | 745 | data.attrs[dataPropertyStoreKey] = data.key;
|
743 | 746 | data.attrs[dataPropertyPath] = data.path;
|
744 | 747 | data.attrs[dataPropertyUiPath] = data.ui;
|
745 |
| - return openTag(data.tag, data.attrs) + closeTag(data.tag); |
| 748 | + return htmlTag(data.tag, data.attrs); |
746 | 749 | });
|
747 | 750 | // DEBUG
|
748 | 751 | if (tag !== 'html' && tag !== 'body') {
|
|
0 commit comments