* Callback for pcdata. Some text nodes can trigger the start of the body * region. * @param {string} text
(text)
| 392 | * @param {string} text |
| 393 | */ |
| 394 | pcdata(text) { |
| 395 | if (SPACE_RE_.test(text)) { |
| 396 | // Only ASCII whitespace; this can be ignored for validator's purposes. |
| 397 | } else if (CPP_SPACE_RE_.test(text)) { |
| 398 | // Non-ASCII whitespace; if this occurs outside <body>, output a |
| 399 | // manufactured-body error. Do not create implicit tags, in order to match |
| 400 | // the behavior of the buggy C++ parser. (It just so happens this is also |
| 401 | // good UX, since the subsequent validation errors caused by the implicit |
| 402 | // tags are unhelpful.) |
| 403 | switch (this.region_) { |
| 404 | // Fallthroughs intentional. |
| 405 | case TagRegion.PRE_DOCTYPE: |
| 406 | case TagRegion.PRE_HTML: |
| 407 | case TagRegion.PRE_HEAD: |
| 408 | case TagRegion.IN_HEAD: |
| 409 | case TagRegion.PRE_BODY: |
| 410 | if (this.handler_.markManufacturedBody) { |
| 411 | this.handler_.markManufacturedBody(); |
| 412 | } |
| 413 | } |
| 414 | } else { |
| 415 | // Non-whitespace text; if this occurs outside <body>, output a |
| 416 | // manufactured-body error and create the necessary implicit tags. |
| 417 | switch (this.region_) { |
| 418 | // Fallthroughs intentional. |
| 419 | case TagRegion.PRE_DOCTYPE: // doctype is not manufactured |
| 420 | case TagRegion.PRE_HTML: |
| 421 | this.startTag(new parserInterface.ParsedHtmlTag('HTML')); |
| 422 | case TagRegion.PRE_HEAD: |
| 423 | this.startTag(new parserInterface.ParsedHtmlTag('HEAD')); |
| 424 | case TagRegion.IN_HEAD: |
| 425 | this.endTag(new parserInterface.ParsedHtmlTag('HEAD')); |
| 426 | case TagRegion.PRE_BODY: |
| 427 | if (this.handler_.markManufacturedBody) { |
| 428 | this.handler_.markManufacturedBody(); |
| 429 | } |
| 430 | this.startTag(new parserInterface.ParsedHtmlTag('BODY')); |
| 431 | } |
| 432 | } |
| 433 | this.handler_.pcdata(text); |
| 434 | } |
| 435 | |
| 436 | /** |
| 437 | * Upon exiting a tag, validation for the current matcher is triggered, |
no test coverage detected