Blame view

lib/jsdom/living/domparsing/XMLSerializer-impl.js 535 Bytes
858f2bdf5   Boyan Georgiev   fixes
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("domexception/webidl2js-wrapper");
  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"]);
      }
    }
  };