Skip to content

Tags with colons parsed incorrectly #27

@pconerly

Description

@pconerly

svg tags can have an attribute named "xmlns:xlink". For example:
<svg aria-hidden="true" style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

When parsed by HTML.parse it incorrectly parses the tags.

test script: ast_test.ts

import HTML from 'html-parse-stringify';

export const problemSvg = `<svg aria-hidden="true" style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" data-webdiff-id="175">
</svg>`;

const problem = HTML.parse(problemSvg);

console.log('problem', problem);

output:

$ ./node_modules/.bin/ts-node ast_test.ts 
problem [ { type: 'tag',
    name: 'svg',
    voidElement: false,
    attrs: 
     { 'aria-hidden': 'true',
       style: 'position: absolute; width: 0; height: 0; overflow: hidden;',
       version: '1.1',
       xmlns: 'xlink',
       '"http://www.w3.org/1999/xlink"': 'data-webdiff-id' },
    children: [ [Object], [Object] ] } ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions