(tag, parentTag)
| 7289 | |
| 7290 | |
| 7291 | var isTagValidWithParent = function (tag, parentTag) { |
| 7292 | // First, let's check if we're in an unusual parsing mode... |
| 7293 | switch (parentTag) { |
| 7294 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect |
| 7295 | case 'select': |
| 7296 | return tag === 'option' || tag === 'optgroup' || tag === '#text'; |
| 7297 | |
| 7298 | case 'optgroup': |
| 7299 | return tag === 'option' || tag === '#text'; |
| 7300 | // Strictly speaking, seeing an <option> doesn't mean we're in a <select> |
| 7301 | // but |
| 7302 | |
| 7303 | case 'option': |
| 7304 | return tag === '#text'; |
| 7305 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd |
| 7306 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption |
| 7307 | // No special behavior since these rules fall back to "in body" mode for |
| 7308 | // all except special table nodes which cause bad parsing behavior anyway. |
| 7309 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr |
| 7310 | |
| 7311 | case 'tr': |
| 7312 | return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template'; |
| 7313 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody |
| 7314 | |
| 7315 | case 'tbody': |
| 7316 | case 'thead': |
| 7317 | case 'tfoot': |
| 7318 | return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template'; |
| 7319 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup |
| 7320 | |
| 7321 | case 'colgroup': |
| 7322 | return tag === 'col' || tag === 'template'; |
| 7323 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable |
| 7324 | |
| 7325 | case 'table': |
| 7326 | return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template'; |
| 7327 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead |
| 7328 | |
| 7329 | case 'head': |
| 7330 | return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template'; |
| 7331 | // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element |
| 7332 | |
| 7333 | case 'html': |
| 7334 | return tag === 'head' || tag === 'body' || tag === 'frameset'; |
| 7335 | |
| 7336 | case 'frameset': |
| 7337 | return tag === 'frame'; |
| 7338 | |
| 7339 | case '#document': |
| 7340 | return tag === 'html'; |
| 7341 | } // Probably in the "in body" parsing mode, so we outlaw only tag combos |
| 7342 | // where the parsing rules cause implicit opens or closes to be added. |
| 7343 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody |
| 7344 | |
| 7345 | |
| 7346 | switch (tag) { |
| 7347 | case 'h1': |
| 7348 | case 'h2': |
no outgoing calls
no test coverage detected