Kiltarc Kiltarc - 1 month ago 12
iOS Question

iOS Safari NodeIterator nextNode returns null

Safari on iPhone 6 with iOS 9 returns in this example

null
:

HTML:

<template id="example">
<p>Hello world!</p>
<p>Hello world!</p>
<p>Hello world!</p>
</template>


Javascript:

var SourceNode = document.getElementById("example");
var TemplateNode = document.importNode(SourceNode.content, true);
var Nodes = document.createNodeIterator(TemplateNode);

console.log(Nodes.nextNode());

var Node;
while(Node = Nodes.nextNode())
{
console.log("foo");
}


foo
in the while loop get's never outputed.

console.log(Nodes.nextNode());
outputs
null
.

It works in current Chrome, Firefox and Edge.

jsFiddle: https://jsfiddle.net/LdtxLuvh/1/

Anything wrong with my code or a bug?

Answer

After updating to iOS 10 anything works, so I think it's an iOS 9 related bug.

Comments