Skip to content

Instantly share code, notes, and snippets.

@caisui
Last active December 16, 2015 06:59
Show Gist options
  • Save caisui/5395518 to your computer and use it in GitHub Desktop.
Save caisui/5395518 to your computer and use it in GitHub Desktop.
diff --git a/common/content/util.js b/common/content/util.js
--- a/common/content/util.js
+++ b/common/content/util.js
@@ -782,12 +782,12 @@
* @see util.xmlToDom
*/
xmlToDomForTemplate: function xmlToDomForTemplate(node, doc, nodes) {
- var dom = doc.createDocumentFragment();
var range = doc.createRange();
var fragment = range.createContextualFragment(
xml`<div xmlns:ns=${NS} xmlns:xul=${XUL} xmlns=${XHTML}>${node}</div>`.toString());
- while (fragment.firstChild.childNodes.length > 0)
- dom.appendChild(fragment.firstChild.firstChild)
+
+ range.selectNodeContents(fragment.firstChild);
+ var dom = range.extractContents();
range.detach();
@caisui
Copy link
Author

caisui commented Apr 16, 2013

ああ 宣言が 抜けてますね…orz

@caisui
Copy link
Author

caisui commented Apr 16, 2013

付けました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment