Skip to content

Commit 9bbc7f3

Browse files
committed
Fix HTML in SVG in HTML
Closes GH-18.
1 parent 9ae39c7 commit 9bbc7f3

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

lib/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,13 @@ export const raw =
270270
*/
271271
function element(node) {
272272
resetTokenizer()
273-
parser._processToken(startTag(node), webNamespaces.html)
273+
parser._processInputToken(startTag(node))
274274

275275
all(node.children)
276276

277277
if (!htmlVoidElements.includes(node.tagName)) {
278278
resetTokenizer()
279-
parser._processToken(endTag(node))
279+
parser._processInputToken(endTag(node))
280280
}
281281
}
282282

@@ -286,7 +286,7 @@ export const raw =
286286
*/
287287
function text(node) {
288288
resetTokenizer()
289-
parser._processToken({
289+
parser._processInputToken({
290290
type: characterToken,
291291
chars: node.value,
292292
location: createParse5Location(node)
@@ -299,7 +299,7 @@ export const raw =
299299
*/
300300
function doctype(node) {
301301
resetTokenizer()
302-
parser._processToken({
302+
parser._processInputToken({
303303
type: doctypeToken,
304304
name: 'html',
305305
forceQuirks: false,
@@ -315,7 +315,7 @@ export const raw =
315315
*/
316316
function comment(node) {
317317
resetTokenizer()
318-
parser._processToken({
318+
parser._processInputToken({
319319
type: commentToken,
320320
data: node.value,
321321
location: createParse5Location(node)
@@ -427,7 +427,7 @@ export const raw =
427427
token.location.endLine = posTracker.line
428428
token.location.endCol = posTracker.col + 1
429429
token.location.endOffset = posTracker.offset + 1
430-
parser._processToken(token)
430+
parser._processInputToken(token)
431431
}
432432

433433
// Reset tokenizer:

test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import test from 'tape'
77
import {u} from 'unist-builder'
8-
import {h} from 'hastscript'
8+
import {h, s} from 'hastscript'
99
import {unified} from 'unified'
1010
import remarkParse from 'remark-parse'
1111
import remarkRehype from 'remark-rehype'
@@ -188,6 +188,14 @@ test('raw', (t) => {
188188
'should support template nodes'
189189
)
190190

191+
t.deepEqual(
192+
raw(u('root', [h('p', [h('svg', [s('foreignObject', [h('div')])])])])),
193+
u('root', {data: {quirksMode: false}}, [
194+
h('p', [h('svg', [s('foreignObject', [h('div')])])])
195+
]),
196+
'should support HTML in SVG in HTML'
197+
)
198+
191199
t.deepEqual(
192200
raw(u('root', [u('raw', '<i'), h('b')])),
193201
u('root', {data: {quirksMode: false}}, [h('b')]),

0 commit comments

Comments
 (0)