mirror of
https://github.com/github/semantic.git
synced 2024-11-29 02:44:36 +03:00
Extract a function to add text and child nodes.
This commit is contained in:
parent
e706bb9270
commit
43c9ae3f35
@ -116,17 +116,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (model instanceof Indexed) {
|
||||
element = document.createElement("ul");
|
||||
if (model.source != null && model.range != null) {
|
||||
var previous = model.range[0];
|
||||
for (i in model.values) {
|
||||
var value = model.values[i];
|
||||
element.appendChild(document.createTextNode(model.source.substr(previous, value.range[0] - previous)));
|
||||
function addTextAndChildNodes(element, source, range, values) {
|
||||
var previous = range[0];
|
||||
for (i in values) {
|
||||
var value = values[i];
|
||||
element.appendChild(document.createTextNode(source.substr(previous, value.range[0] - previous)));
|
||||
element.appendChild(wrap("li", toDOM(value)));
|
||||
previous = value.range[0] + value.range[1];
|
||||
}
|
||||
element.appendChild(document.createTextNode(model.source.substr(previous, model.range[0] + model.range[1] - previous)));
|
||||
element.appendChild(document.createTextNode(source.substr(previous, range[0] + range[1] - previous)));
|
||||
}
|
||||
|
||||
if (model instanceof Indexed) {
|
||||
element = document.createElement("ul");
|
||||
if (model.source != null && model.range != null) {
|
||||
addTextAndChildNodes(element, model.source, model.range, model.values);
|
||||
} else {
|
||||
for (i in model.values) {
|
||||
element.appendChild(wrap("li", toDOM(model.values[i])));
|
||||
|
Loading…
Reference in New Issue
Block a user