You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.3 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
  3. * http://paperjs.org/
  4. *
  5. * Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
  6. * http://juerglehni.com/ & https://puckey.studio/
  7. *
  8. * Distributed under the MIT license. See LICENSE file for details.
  9. *
  10. * All rights reserved.
  11. */
  12. module.exports = function(self) {
  13. // Define XMLSerializer shim, to emulate browser behavior.
  14. // Effort to bring XMLSerializer to jsdom:
  15. // https://github.com/tmpvar/jsdom/issues/1368
  16. self.XMLSerializer = function XMLSerializer() {
  17. };
  18. self.XMLSerializer.prototype = {
  19. serializeToString: function(node) {
  20. if (!node)
  21. return '';
  22. // Fix a jsdom issue where all SVG tagNames are lowercased:
  23. // https://github.com/tmpvar/jsdom/issues/620
  24. var text = node.outerHTML,
  25. tagNames = ['linearGradient', 'radialGradient', 'clipPath',
  26. 'textPath'];
  27. for (var i = 0, l = tagNames.length; i < l; i++) {
  28. var tagName = tagNames[i];
  29. text = text.replace(
  30. new RegExp('(<|</)' + tagName.toLowerCase() + '\\b', 'g'),
  31. function(match, start) {
  32. return start + tagName;
  33. });
  34. }
  35. return text;
  36. }
  37. };
  38. };