{"action":"created","issue":{"url":"https://api.github.com/repos/tmpvar/jsdom/issues/1368","repository_url":"https://api.github.com/repos/tmpvar/jsdom","labels_url":"https://api.github.com/repos/tmpvar/jsdom/issues/1368/labels{/name}","comments_url":"https://api.github.com/repos/tmpvar/jsdom/issues/1368/comments","events_url":"https://api.github.com/repos/tmpvar/jsdom/issues/1368/events","html_url":"https://github.com/tmpvar/jsdom/issues/1368","id":129068012,"number":1368,"title":"Implement DOMParser and XMLSerializer classes","user":{"login":"lehni","id":213275,"avatar_url":"https://avatars.githubusercontent.com/u/213275?v=3","gravatar_id":"","url":"https://api.github.com/users/lehni","html_url":"https://github.com/lehni","followers_url":"https://api.github.com/users/lehni/followers","following_url":"https://api.github.com/users/lehni/following{/other_user}","gists_url":"https://api.github.com/users/lehni/gists{/gist_id}","starred_url":"https://api.github.com/users/lehni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lehni/subscriptions","organizations_url":"https://api.github.com/users/lehni/orgs","repos_url":"https://api.github.com/users/lehni/repos","events_url":"https://api.github.com/users/lehni/events{/privacy}","received_events_url":"https://api.github.com/users/lehni/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/tmpvar/jsdom/labels/feature","name":"feature","color":"02e10c"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":17,"created_at":"2016-01-27T08:24:09Z","updated_at":"2016-08-15T18:10:46Z","closed_at":null,"body":"All modern browsers expose these two useful classes with both a very simple API:\r\n\r\nhttps://developer.mozilla.org/en/docs/Web/API/DOMParser\r\nhttps://developer.mozilla.org/en/docs/XMLSerializer\r\n\r\nWithout knowing the details, I believe it shouldn't be too hard to implement these as thin shim to what jsdom already has available.\r\n\r\nI am currently using quickly hacked together shims in paper.js that look like the code below.\r\n\r\nI am happy to work on a better version that can find its way into jsdom, if you think this would be useful and could give me some pointers as to where to start looking.\r\n\r\n```js\r\nfunction XMLSerializer() {\r\n}\r\n\r\nXMLSerializer.prototype.serializeToString = function(node) {\r\n    var text = jsdom.serializeDocument(node);\r\n    // Fix a jsdom issue where all SVG tagNames are lowercased:\r\n    // https://github.com/tmpvar/jsdom/issues/620\r\n    var tagNames = ['linearGradient', 'radialGradient', 'clipPath', 'textPath'];\r\n    for (var i = 0, l = tagNames.length; i < l; i++) {\r\n        var tagName = tagNames[i];\r\n        text = text.replace(\r\n            new RegExp('(<|</)' + tagName.toLowerCase() + '\\\\b', 'g'),\r\n            function(all, start) {\r\n                return start + tagName;\r\n            });\r\n    }\r\n    return text;\r\n};\r\n\r\nfunction DOMParser() {\r\n}\r\n\r\nDOMParser.prototype.parseFromString = function(string, contenType) {\r\n    var div = document.createElement('div');\r\n    div.innerHTML = string;\r\n    return div.firstChild;\r\n};\r\n```"},"comment":{"url":"https://api.github.com/repos/tmpvar/jsdom/issues/comments/239880412","html_url":"https://github.com/tmpvar/jsdom/issues/1368#issuecomment-239880412","issue_url":"https://api.github.com/repos/tmpvar/jsdom/issues/1368","id":239880412,"user":{"login":"domenic","id":617481,"avatar_url":"https://avatars.githubusercontent.com/u/617481?v=3","gravatar_id":"","url":"https://api.github.com/users/domenic","html_url":"https://github.com/domenic","followers_url":"https://api.github.com/users/domenic/followers","following_url":"https://api.github.com/users/domenic/following{/other_user}","gists_url":"https://api.github.com/users/domenic/gists{/gist_id}","starred_url":"https://api.github.com/users/domenic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domenic/subscriptions","organizations_url":"https://api.github.com/users/domenic/orgs","repos_url":"https://api.github.com/users/domenic/repos","events_url":"https://api.github.com/users/domenic/events{/privacy}","received_events_url":"https://api.github.com/users/domenic/received_events","type":"User","site_admin":false},"created_at":"2016-08-15T18:10:46Z","updated_at":"2016-08-15T18:10:46Z","body":"Oh, yeah, that won't work. You need to use an actual jsdom, e.g.\r\n\r\n```js\r\nconst DOMParser = jsdom.jsdom().defaultView.DOMParser;\r\n```\r\n\r\nAnyway, I still don't understand what properties you're talking about, exactly. `document.SymbolTreeNode` and `document.Document` are undefined in real browsers too, not just jsdom."}}
{"actor":{"display_login":"domenic"}}