@journeyapps/core-xml
Advanced tools
Comparing version 0.0.0-dev.4073ebe3.cae5e07 to 0.0.0-dev.40ce648
@@ -16,2 +16,2 @@ import { XMLElement } from '@journeyapps/domparser/types'; | ||
} | ||
export declare type UpdateFunction = (element: XMLElement) => void; | ||
export type UpdateFunction = (element: XMLElement) => void; |
import { XMLNode, XMLSerializer } from '@journeyapps/domparser/types'; | ||
import { XMLNodeLike } from '@journeyapps/domparser/lib/XMLNode'; | ||
declare type NodeFilter = (node: XMLNodeLike) => XMLNode | string; | ||
type NodeFilter = (node: XMLNodeLike) => XMLNode | string; | ||
export declare const serializer: XMLSerializer; | ||
export declare function serialize(node: XMLNodeLike, nodeFilter?: NodeFilter): string; | ||
export {}; |
@@ -30,3 +30,3 @@ import { XMLElement, XMLPosition, XMLDocument } from '@journeyapps/domparser/types'; | ||
export declare function getAttribute(elem: XMLElement, key: string): string | null; | ||
export declare type XMLPositional = XMLElement | AttributeNode | [XMLElement | AttributeNode, number, number] | XMLRange; | ||
export type XMLPositional = XMLElement | AttributeNode | [XMLElement | AttributeNode, number, number] | XMLRange; | ||
export declare function getPosition(input: XMLPositional): XMLRange; | ||
@@ -36,3 +36,3 @@ export declare function attributeValuePosition(element: XMLElement, attributeName: string, start: number, end: number): XMLRange; | ||
export declare function attributeNode(element: XMLElement, attributeName: string): AttributeNode; | ||
export declare type ErrorType = 'warning' | 'error'; | ||
export type ErrorType = 'warning' | 'error'; | ||
export declare function error(element: XMLPositional, message: string, type?: ErrorType): ValidationError; | ||
@@ -39,0 +39,0 @@ export declare function warning(element: XMLPositional, message: string): ValidationError; |
@@ -10,6 +10,7 @@ "use strict"; | ||
// and @journeyapps/domparser for parsing. | ||
//@ts-ignore | ||
const implementation = document.implementation; | ||
const parser = new domparser_1.DOMParser({ implementation }); | ||
const serializer = new XMLSerializer(); | ||
xml_1.configureParser({ | ||
(0, xml_1.configureParser)({ | ||
implementation, | ||
@@ -28,3 +29,3 @@ parser, | ||
const serializer = new xmldom.XMLSerializer(); | ||
xml_1.configureParser({ | ||
(0, xml_1.configureParser)({ | ||
implementation, | ||
@@ -31,0 +32,0 @@ parser, |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -5,3 +5,7 @@ "use strict"; | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -8,0 +12,0 @@ if (k2 === undefined) k2 = k; |
@@ -78,7 +78,7 @@ "use strict"; | ||
} | ||
else if (index_1.isElement(child) && this.tagMap[child.tagName]) { | ||
else if ((0, index_1.isElement)(child) && this.tagMap[child.tagName]) { | ||
// A known element that isn't inserted already. | ||
// Skip it. | ||
} | ||
else if (index_1.isText(child) && this.textContent !== undefined) { | ||
else if ((0, index_1.isText)(child) && this.textContent !== undefined) { | ||
// Skip any nodes after the first one. | ||
@@ -85,0 +85,0 @@ if (!seenSourceText) { |
@@ -17,3 +17,3 @@ "use strict"; | ||
const child = document.childNodes.item(i); | ||
if (utils_1.isText(child)) { | ||
if ((0, utils_1.isText)(child)) { | ||
// workaround for xmldom that has text nodes in the document | ||
@@ -61,3 +61,3 @@ continue; | ||
const child = children[i]; | ||
if (utils_1.isText(child)) { | ||
if ((0, utils_1.isText)(child)) { | ||
// Workaround for xmldom inserting extra newlines | ||
@@ -107,3 +107,3 @@ continue; | ||
let newNode = node.cloneNode(false); | ||
if (utils_1.isText(node)) { | ||
if ((0, utils_1.isText)(node)) { | ||
const trimmedText = node.nodeValue.trim(); | ||
@@ -126,3 +126,3 @@ const newLines = node.nodeValue.split('\n').length - 1; | ||
} | ||
else if (utils_1.isElement(node)) { | ||
else if ((0, utils_1.isElement)(node)) { | ||
let filteredChildren = []; | ||
@@ -134,3 +134,3 @@ for (let i = 0; i < node.childNodes.length; i++) { | ||
filteredChildren = filteredChildren.filter((node) => node != null); | ||
if (filteredChildren.length == 1 && utils_1.isText(filteredChildren[0])) { | ||
if (filteredChildren.length == 1 && (0, utils_1.isText)(filteredChildren[0])) { | ||
// Text on its own. Preserve whitespace. | ||
@@ -161,3 +161,3 @@ newNode.appendChild(filteredChildren[0]); | ||
else { | ||
if (utils_1.isText(child)) { | ||
if ((0, utils_1.isText)(child)) { | ||
// Text in mixed-mode. | ||
@@ -164,0 +164,0 @@ // We currently preserve whitespace _before_ the text element, but not _after_. |
@@ -59,3 +59,3 @@ "use strict"; | ||
} | ||
if (utils_1.isElement(node)) { | ||
if ((0, utils_1.isElement)(node)) { | ||
if (!visibleNamespaces) { | ||
@@ -121,12 +121,12 @@ visibleNamespaces = []; | ||
} | ||
else if (utils_1.isAttribute(node)) { | ||
else if ((0, utils_1.isAttribute)(node)) { | ||
buf.push(' ', node.name, '="', node.value.replace(/[<&"]/g, _xmlEncoder), '"'); | ||
} | ||
else if (utils_1.isText(node)) { | ||
else if ((0, utils_1.isText)(node)) { | ||
buf.push(node.data.replace(/[<&]/g, _xmlEncoder)); | ||
} | ||
else if (utils_1.isCdataNode(node)) { | ||
else if ((0, utils_1.isCdataNode)(node)) { | ||
buf.push('<![CDATA[', node.data, ']]>'); | ||
} | ||
else if (utils_1.isCommentNode(node)) { | ||
else if ((0, utils_1.isCommentNode)(node)) { | ||
buf.push('<!--', node.data, '-->'); | ||
@@ -133,0 +133,0 @@ } |
@@ -62,4 +62,4 @@ "use strict"; | ||
// Copy existing children | ||
for (let child of index_1.iter(this.sourceElement.childNodes)) { | ||
if (index_1.isElement(child) && child.tagName in this.sourceElements) { | ||
for (let child of (0, index_1.iter)(this.sourceElement.childNodes)) { | ||
if ((0, index_1.isElement)(child) && child.tagName in this.sourceElements) { | ||
if (this.sourceElements[child.tagName].has(child)) { | ||
@@ -66,0 +66,0 @@ // Present - update! |
@@ -49,3 +49,3 @@ "use strict"; | ||
var owner; | ||
if (utils_1.isAttribute(node)) { | ||
if ((0, utils_1.isAttribute)(node)) { | ||
owner = node.ownerElement.ownerDocument; | ||
@@ -62,3 +62,3 @@ } | ||
} | ||
else if (utils_1.isElement(node) && node.openStart != null && node.nameEnd != null) { | ||
else if ((0, utils_1.isElement)(node) && node.openStart != null && node.nameEnd != null) { | ||
// This is an element | ||
@@ -68,3 +68,3 @@ position.start = locator.position(node.openStart + 1); | ||
} | ||
else if (utils_1.isAttribute(node)) { | ||
else if ((0, utils_1.isAttribute)(node)) { | ||
// This is an attribute | ||
@@ -338,3 +338,3 @@ var attrPosition = node.ownerElement.attributePositions == null ? null : node.ownerElement.attributePositions[node.name]; | ||
var child = all[i]; | ||
if (utils_1.isElement(child) && | ||
if ((0, utils_1.isElement)(child) && | ||
child.tagName != null && | ||
@@ -352,3 +352,3 @@ (allowedNames == null || allowedNames.indexOf(child.tagName) != -1)) { | ||
Array.prototype.forEach.call(element.childNodes, function (child) { | ||
if (utils_1.isElement(child)) { | ||
if ((0, utils_1.isElement)(child)) { | ||
var tag = child.tagName; | ||
@@ -386,3 +386,5 @@ var order = tagNames[tag]; | ||
configureParser({ | ||
//@ts-ignore | ||
implementation: document.implementation, | ||
//@ts-ignore | ||
parser: new DOMParser(), | ||
@@ -421,3 +423,3 @@ serializer: new XMLSerializer() | ||
var child = element.childNodes[i]; | ||
if (utils_1.isElement(child) && child.tagName == childName) { | ||
if ((0, utils_1.isElement)(child) && child.tagName == childName) { | ||
return child; | ||
@@ -424,0 +426,0 @@ } |
{ | ||
"name": "@journeyapps/core-xml", | ||
"version": "0.0.0-dev.4073ebe3.cae5e07", | ||
"description": "Journey JS library", | ||
"version": "0.0.0-dev.40ce648", | ||
"description": "Journey XML library", | ||
"main": "./dist/src/node.js", | ||
"browser": "./dist/src/index.js", | ||
"typings": "./dist/@types/src/index", | ||
"scripts": { | ||
"build": "../node_modules/.bin/tsc --build", | ||
"test": "yarn build && yarn test:node && yarn test:browser", | ||
"test:browser": "karma start karma.conf.js --single-run", | ||
"test:node": "jasmine dist/test/unit/all.js" | ||
}, | ||
"dependencies": { | ||
"@journeyapps/domparser": "^0.3.0" | ||
"@journeyapps/domparser": "^0.4.1", | ||
"xmldom": "^0.6.0" | ||
}, | ||
"devDependencies": { | ||
"@journeyapps/core-test-helpers": "0.0.0-dev.4073ebe3.cae5e07" | ||
"@journeyapps/core-test-helpers": "^0.0.0-dev.40ce648" | ||
}, | ||
@@ -25,3 +20,8 @@ "files": [ | ||
], | ||
"gitHead": "03fafcf967f666529bcba1be9778d494cef95cd3" | ||
} | ||
"scripts": { | ||
"build": "../node_modules/.bin/tsc --build", | ||
"test": "pnpm build && pnpm test:node && pnpm test:browser", | ||
"test:browser": "karma start karma.conf.js --single-run", | ||
"test:node": "jasmine dist/test/unit/all.js" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
155535
39
1437
2
+ Addedxmldom@^0.6.0
+ Added@journeyapps/domparser@0.4.1(transitive)
+ Addedxmldom@0.6.0(transitive)
- Removed@journeyapps/domparser@0.3.0(transitive)