aboutsummaryrefslogtreecommitdiffstats
path: root/vanilla/node_modules/jsdom/lib/jsdom/living/domparsing/XMLSerializer-impl.js
blob: 5287fadbd75643b7a98ce1eba2c1a97a928ba898 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"use strict";
const serialize = require("w3c-xmlserializer");
const DOMException = require("../generated/DOMException");
const utils = require("../generated/utils");

exports.implementation = class XMLSerializerImpl {
  constructor(globalObject) {
    this._globalObject = globalObject;
  }

  serializeToString(root) {
    try {
      return serialize(utils.wrapperForImpl(root), { requireWellFormed: false });
    } catch (e) {
      throw DOMException.create(this._globalObject, [e.message, "InvalidStateError"]);
    }
  }
};