Last modified: 2014-03-26 23:34:52 UTC
To figure out: * Does this work in all browsers we support? I have anecdotally confirmed support in Firefox 25 and Chrome 30 * Protocol-relative URLs in <base> are broken, because documents created this way don't have a creator context or whatever. Benefits: * Not a hack involving iframes :) * Faster than the iframe hack * Does not have issues with HTTPSEverywhere in Firefox For the <base> issue, it looks like something like this will work: >>> d.querySelector('base') <base href="//example.com"> >>> d.baseURI null >>> d.querySelector('base').getAttribute('href') "//example.com" >>> d.querySelector('base').setAttribute('href', 'http://example.com'); undefined >>> d.baseURI "http://example.com/"
(In reply to comment #0) > For the <base> issue, it looks like something like this will work: > I read the spec some more and it looks like the trick I outlined is actually something that the spec specifically covers and says should work. Other issue: we can't parse doctypes or <html> tags this way, so we can't respect non-HTML5 doctypes and we won't see any attributes on the <html> element. This isn't a problem for Parsoid documents at this time, although it'll be pretty annoying if we ever want to respect things like <html lang="nl">.
...or use DOMParser, which actually does *precisely* what we want. We could use it in browsers where it's available as a replacement for ve.createDocumentFromHtml, because it's supported only in FF 12+, Chrome 30+ (!), IE 10+, Opera 17+ (!) and not at all (!!) in Safari.
Change 120836 had a related patch set uploaded by Catrope: Use DOMParser in ve.createDocumentFromHtml() if available https://gerrit.wikimedia.org/r/120836
(In reply to Roan Kattouw from comment #2) > ...or use DOMParser, which actually does *precisely* what we want. We could > use it in browsers where it's available as a replacement for > ve.createDocumentFromHtml, because it's supported only in FF 12+, Chrome 30+ > (!), IE 10+, Opera 17+ (!) and not at all (!!) in Safari. This is what I ended up going with.
Change 120836 merged by jenkins-bot: Use DOMParser in ve.createDocumentFromHtml() if available https://gerrit.wikimedia.org/r/120836