Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency xmldom #540

Merged
merged 2 commits into from Dec 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -45,12 +45,12 @@
"bugs": "http://github.com/linkeddata/rdflib.js/issues",
"dependencies": {
"@babel/runtime": "^7.16.0",
"@xmldom/xmldom": "^0.8.0",
"async": "^3.2.2",
"cross-fetch": "^3.1.4",
"jsonld": "^5.2.0",
"n3": "^1.12.2",
"solid-namespace": "^0.5.2",
"xmldom": "^0.6.0"
"solid-namespace": "^0.5.2"
},
"devDependencies": {
"@babel/cli": "^7.16.0",
Expand Down
11 changes: 9 additions & 2 deletions src/fetcher.ts
Expand Up @@ -343,6 +343,11 @@ class XMLHandler extends Handler {
fetcher.mediatypes['application/xml'] = { 'q': 0.5 }
}

static isElement(node: Node): node is Element {
return node.nodeType === Node.ELEMENT_NODE;
}


parse (
fetcher: Fetcher,
responseText: string,
Expand All @@ -357,10 +362,12 @@ class XMLHandler extends Handler {
// XML Semantics defined by root element namespace
// figure out the root element
for (let c = 0; c < dom.childNodes.length; c++) {
const node = dom.childNodes[c]
// is this node an element?
if (dom.childNodes[c].nodeType === 1) {
if (XMLHandler.isElement(node)) {

// We've found the first element, it's the root
let ns = dom.childNodes[c].namespaceURI
let ns = node.namespaceURI

// Is it RDF/XML?
if (ns && ns === ns['rdf']) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils-js.js
Expand Up @@ -245,10 +245,10 @@ export function output (o) {
document.body.appendChild(k)
}

import { DOMParser } from 'xmldom'
import { DOMParser } from '@xmldom/xmldom'

/**
* Returns a DOM from parsex XML.
* Returns a DOM from parsed XML.
*/
export function parseXML (str, options) {
var dparser
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Expand Up @@ -29,13 +29,13 @@ module.exports = (env, args) => {
resolve: { extensions: ['.js', '.ts'] },
externals: {
'@trust/webcrypto': 'crypto',
'@xmldom/xmldom': 'window',
'child_process': 'null',
'node-fetch': 'fetch',
'text-encoding': 'TextEncoder',
'whatwg-url': 'window',
'isomorphic-fetch': 'fetch',
'fs': 'null',
'xmldom': 'window'
},
devtool: 'source-map'
}
Expand Down