Merge pull request #923 from iamjohnlong/safari-createContextualFragment-fix
Moves createContextualFragment into try/catch function
This commit is contained in:
commit
e32f37c523
3 changed files with 24 additions and 10 deletions
12
mithril.js
12
mithril.js
|
|
@ -626,6 +626,13 @@ var m = (function app(window, undefined) {
|
|||
else if (cached.children.tag) unload(cached.children);
|
||||
}
|
||||
}
|
||||
function appendTextFragment(parentElement, data) {
|
||||
try {
|
||||
parentElement.appendChild($document.createRange().createContextualFragment(data));
|
||||
} catch (e) {
|
||||
parentElement.insertAdjacentHTML("beforeend", data);
|
||||
}
|
||||
}
|
||||
function injectHTML(parentElement, index, data) {
|
||||
var nextSibling = parentElement.childNodes[index];
|
||||
if (nextSibling) {
|
||||
|
|
@ -639,10 +646,7 @@ var m = (function app(window, undefined) {
|
|||
else nextSibling.insertAdjacentHTML("beforebegin", data);
|
||||
}
|
||||
else {
|
||||
if (window.Range && window.Range.prototype.createContextualFragment) {
|
||||
parentElement.appendChild($document.createRange().createContextualFragment(data));
|
||||
}
|
||||
else parentElement.insertAdjacentHTML("beforeend", data);
|
||||
appendTextFragment(parentElement, data);
|
||||
}
|
||||
var nodes = [];
|
||||
while (parentElement.childNodes[index] !== nextSibling) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue