Skip to content

Instantly share code, notes, and snippets.

@stephenjudkins
Created May 20, 2014 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephenjudkins/801de2af854245e9f14f to your computer and use it in GitHub Desktop.
Save stephenjudkins/801de2af854245e9f14f to your computer and use it in GitHub Desktop.
Hacky fix to IE11 multiple adjacent text nodes problem for Angular
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