Skip to content

querySelector doesn't deal with xml namespaces #2159

@johanneswilm

Description

@johanneswilm

Basic info:

  • Node.js version: n/a (current Chrome w/browserify)
  • jsdom version: 11.6.2

Minimal reproduction case

import {JSDOM} from "jsdom"

let jsdom = new JSDOM()
let parser = new jsdom.jsdom.window.DOMParser()
let string = `<?xml version="1.0"?><cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:title></dc:title></cp:coreProperties>`
let dom = parser.parseFromString(string, 'text/xml')
let el = dom.querySelector('coreProperties')
console.log(el) 

The console gives an output of null, meaning it cannot find the cp:coreProperties element

How does similar code behave in browsers?

This works fine in Chrome/Firefox:

let parser = new window.DOMParser()
let string = `<?xml version="1.0"?><cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:title></dc:title></cp:coreProperties>`
let dom = parser.parseFromString(string, 'text/xml')
let el = dom.querySelector('coreProperties')
console.log(el) 

The console gives an output of the cp:coreProperties element.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions