Skip to content

Commit

Permalink
Merge pull request #6063 from Andrew8xx8/master
Browse files Browse the repository at this point in the history
Wrap insertBefore in Windows 8 apps
  • Loading branch information
jimfb committed Feb 18, 2016
2 parents 3a4e1db + 8d08f3f commit 5879c9e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/renderers/dom/client/utils/DOMChildrenOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* @providesModule DOMChildrenOperations
*/

/* globals MSApp */

'use strict';

var DOMLazyTree = require('DOMLazyTree');
Expand All @@ -35,7 +37,14 @@ function insertChildAt(parentNode, childNode, referenceNode) {
// We rely exclusively on `insertBefore(node, null)` instead of also using
// `appendChild(node)`. (Using `undefined` is not allowed by all browsers so
// we are careful to use `null`.)
parentNode.insertBefore(childNode, referenceNode);

if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
MSApp.execUnsafeLocalFunction(function() {
parentNode.insertBefore(childNode, referenceNode);
});
} else {
parentNode.insertBefore(childNode, referenceNode);
}
}

function insertLazyTreeChildAt(parentNode, childTree, referenceNode) {
Expand Down
11 changes: 10 additions & 1 deletion src/renderers/dom/client/utils/DOMLazyTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* @providesModule DOMLazyTree
*/

/* globals MSApp */

'use strict';

var setTextContent = require('setTextContent');
Expand Down Expand Up @@ -51,7 +53,14 @@ function insertTreeChildren(tree) {
}

function insertTreeBefore(parentNode, tree, referenceNode) {
parentNode.insertBefore(tree.node, referenceNode);
if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
MSApp.execUnsafeLocalFunction(function() {
parentNode.insertBefore(tree.node, referenceNode);
});
} else {
parentNode.insertBefore(tree.node, referenceNode);
}

insertTreeChildren(tree);
}

Expand Down

0 comments on commit 5879c9e

Please sign in to comment.