FIX: prevent pollception

This commit is contained in:
Régis Hanol
2015-05-13 23:12:53 +02:00
parent 8fa109638b
commit 7c545537a6
2 changed files with 18 additions and 5 deletions
@@ -67,11 +67,18 @@
}
}
// make sure the first child is a list with at least 1 option
if (contents.length === 0 || contents[0].length <= 1 || (contents[0][0] !== "numberlist" && contents[0][0] !== "bulletlist")) {
// make sure there's only 1 child and it's a list with at least 1 option
if (contents.length !== 1 || contents[0].length <= 1 || (contents[0][0] !== "numberlist" && contents[0][0] !== "bulletlist")) {
return ["div"].concat(contents);
}
// make sure there's only options in the list
for (o = 1; o < contents[0].length; o++) {
if (contents[0][o][0] !== "listitem") {
return ["div"].concat(contents);
}
}
// TODO: remove non whitelisted content
// generate <li> styles (if any)
@@ -86,9 +93,6 @@
// add option id (hash) + style
for (o = 1; o < contents[0].length; o++) {
// break as soon as the list is done
if (contents[0][o][0] !== "listitem") { break; }
var attr = {};
// apply styles if any
if (style.length > 0) { attr["style"] = style; }