Created
May 20, 2014 17:48
-
-
Save stephenjudkins/801de2af854245e9f14f to your computer and use it in GitHub Desktop.
Hacky fix to IE11 multiple adjacent text nodes problem for Angular
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
isText = (node) -> node && node.nodeType == Node.TEXT_NODE | |
normalizeNode = (node) -> | |
lastSibling = null | |
for child in (node?.childNodes || []) | |
if isText(child) and isText(lastSibling) | |
combined = lastSibling.nodeValue + child.nodeValue | |
child.nodeValue = combined | |
node.removeChild(lastSibling) | |
else | |
normalizeNode(child) | |
lastSibling = child | |
angular.module("camxm").config ($provide) -> | |
$provide.decorator "$compile", [ | |
"$delegate", | |
($compile) -> | |
($compileNodes, transcludeFn, maxPriority, ignoreDirective, previousCompileContext) -> | |
wrapped = $($compileNodes) | |
wrapped.get().forEach (node) -> normalizeNode(node) | |
$compile(wrapped, transcludeFn, maxPriority, ignoreDirective, previousCompileContext) | |
] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment