Skip to content

Commit

Permalink
Only match title, style, script lowercase variants (#81)
Browse files Browse the repository at this point in the history
Only match `title`, `style`, `script` lowercase variants
  • Loading branch information
rwjblue committed Jan 30, 2020
2 parents 6606143 + d7c91be commit 1036d9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/evented-tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class EventedTokenizer {
}

private isIgnoredEndTag(): boolean {
let tag = this.tagNameBuffer.toLowerCase();
let tag = this.tagNameBuffer;

return (tag === 'title' && this.input.substring(this.index, this.index + 8) !== '</title>') ||
(tag === 'style' && this.input.substring(this.index, this.index + 8) !== '</style>') ||
Expand Down Expand Up @@ -146,7 +146,7 @@ export default class EventedTokenizer {

data() {
let char = this.peek();
let tag = this.tagNameBuffer.toLowerCase();
let tag = this.tagNameBuffer;

if (char === '<' && !this.isIgnoredEndTag()) {
this.delegate.finishData();
Expand Down
6 changes: 6 additions & 0 deletions tests/tokenizer-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ QUnit.test('The title element content is always text', function(assert) {
assert.deepEqual(tokens, [startTag('title'), chars('"hey <b>there</b><!-- comment -->'), endTag('title')]);
});

// https://github.com/emberjs/ember.js/issues/18530
QUnit.test('Title element content is not text', function(assert) {
let tokens = tokenize("<Title><!-- hello --></Title>");
assert.deepEqual(tokens, [startTag('Title'), comment(' hello '), endTag('Title')]);
});

// https://html.spec.whatwg.org/multipage/semantics.html#the-style-element
QUnit.test('The style element content is always text', function(assert) {
let tokens = tokenize("<style>&quot;hey <b>there</b><!-- comment --></style>");
Expand Down

0 comments on commit 1036d9b

Please sign in to comment.