How to use w3c-xmlserializer - 4 common examples

To help you get started, we’ve selected a few w3c-xmlserializer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zotero / translation-server / src / translation / translate.js View on Github external
SandboxManager: require('./sandboxManager'),
	...require('./translate_item')
};
Zotero.Translate.ItemSaver.prototype.saveItems = async function (jsonItems, attachmentCallback, itemsDoneCallback) {
	this.items = (this.items || []).concat(jsonItems)
	return jsonItems
}

// Translation architecture shims and monkey-patches
var wgxpath = require('wicked-good-xpath');
global.XPathResult = wgxpath.XPathResultType;
var { JSDOM } = require('jsdom');
var dom = new JSDOM('');
wgxpath.install(dom.window, true);
global.DOMParser = dom.window.DOMParser;
global.XMLSerializer = require("w3c-xmlserializer/lib/XMLSerializer").interface;
global.Services = {
	// nsIVersionComparator
	vc: {
		compare: function (a, b) {
			// Only worry about the major version (4. vs. 5.)
			var aParts = a.split(/\./g);
			var bParts = b.split(/\./g);
			return aParts[0] - bParts[0];
		}
	}
};

// Shimming innerText property for JSDOM attributes, see https://github.com/jsdom/jsdom/issues/1245
var Attr = require('jsdom/lib/jsdom/living/generated/Attr');
Object.defineProperty(Attr.interface.prototype, 'innerText', {
	get: function() { return this.textContent },
github jsdom / jsdom / lib / jsdom / living / interfaces.js View on Github external
/* eslint-disable global-require */
"use strict";

const DOMException = require("domexception");
const { URL, URLSearchParams } = require("whatwg-url");
const XMLSerializer = require("w3c-xmlserializer/lib/XMLSerializer").interface;

const registerElements = require("./register-elements");
const style = require("../level2/style");
const xpath = require("../level3/xpath");
const nodeFilter = require("./node-filter");

const generatedInterfaces = [
  require("./generated/EventTarget"),

  require("./generated/NamedNodeMap"),
  require("./generated/Attr"),
  require("./generated/Node"),
  require("./generated/Element"),
  require("./generated/DocumentFragment"),
  require("./generated/Document"),
  require("./generated/Document"),
github syntax-tree / hast-util-to-dom / src / utils.js View on Github external
import ns from 'web-namespaces';
// eslint-disable-next-line import/no-extraneous-dependencies
import { XMLSerializer as Serializer } from 'w3c-xmlserializer';

const XMLSerializer = Serializer.interface;

export default function serializeNodeToHtmlString(node) {
  const serialized = new XMLSerializer().serializeToString(node);

  // XMLSerializer puts xmlns on “main” elements that are not in the XML
  // namespace.
  // We’d like to inspect that, but having the HTML namespace everywhere will
  // get unwieldy, so remove those.
  return serialized
    .replace(new RegExp(` xmlns="${ns.html}"`, 'g'), '')
    .replace(new RegExp(`(<(?:svg|g)) xmlns="${ns.svg}"`, 'g'), '$1');
}
github jsdom / jsdom / lib / jsdom / living / index.js View on Github external
exports.History = require("./generated/History").interface;
exports.Screen = require("./generated/Screen").interface;
exports.Performance = require("./generated/Performance").interface;

exports.PluginArray = require("./generated/PluginArray").interface;
exports.MimeTypeArray = require("./generated/MimeTypeArray").interface;
exports.Plugin = require("./generated/Plugin").interface;
exports.MimeType = require("./generated/MimeType").interface;

exports.Blob = require("./generated/Blob").interface;
exports.File = require("./generated/File").interface;
exports.FileList = require("./generated/FileList").interface;
exports.ValidityState = require("./generated/ValidityState").interface;

exports.DOMParser = require("./generated/DOMParser").interface;
exports.XMLSerializer = require("w3c-xmlserializer/lib/XMLSerializer").interface;

exports.FormData = require("./generated/FormData").interface;
exports.XMLHttpRequestEventTarget = require("./generated/XMLHttpRequestEventTarget").interface;
exports.XMLHttpRequestUpload = require("./generated/XMLHttpRequestUpload").interface;

exports.NodeIterator = require("./generated/NodeIterator").interface;
exports.TreeWalker = require("./generated/TreeWalker").interface;

exports.Storage = require("./generated/Storage").interface;

exports.ShadowRoot = require("./generated/ShadowRoot").interface;

exports.MutationObserver = require("./generated/MutationObserver").interface;
exports.MutationRecord = require("./generated/MutationRecord").interface;

require("./register-elements")(exports);

w3c-xmlserializer

A per-spec XML serializer implementation

MIT
Latest version published 1 year ago

Package Health Score

68 / 100
Full package analysis