Ensure selectable container fix

This fixes the issue when inserting a node with a child node but no text content, a```BR``` is added to the wrong place.
E.g. ```<p><b></b></p>``` => ```<p><b></b><br></p>``` when it should be ```<p><b><br></b></p>```
I think it's used in quite a few places already, but I can only recall this
and scribe-plugin-sanitizer.

Oliver Joseph Ash
Software Engineer


On 2 July 2014 15:42, Sébastien Cevey <notifications@github.com> wrote:

> In src/plugins/core/formatters/html/ensure-selectable-containers.js:
>
> >
> >    function traverse(parentNode) {
> > -    var treeWalker = document.createTreeWalker(parentNode, NodeFilter.SHOW_ELEMENT);
> > -    var node = treeWalker.firstChild();
> > +    // Instead of TreeWalker, which gets confused when the BR is added to the dom,
> > +    // we recursively traverse the tree to look for an empty node that can have childNodes
> > +
> > +    var node = parentNode.firstElementChild;
>
> Let's abstract it when we see we need it again?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/guardian/scribe/pull/214/files#r14460335>.
>

-- 

------------------------------
Visit theguardian.com. On your mobile and tablet, download the Guardian 
iPhone and Android apps theguardian.com/guardianapp and our tablet editions 
theguardian.com/editions.  Save up to 57% by subscribing to the Guardian 
and Observer - choose the papers you want and get full digital access. 
 Visit subscribe.theguardian.com

This e-mail and all attachments are confidential and may also be 
privileged. If you are not the named recipient, please notify the sender 
and delete the e-mail and all attachments immediately. Do not disclose the 
contents to another person. You may not use the information for any 
purpose, or store, or copy, it in any way.  Guardian News & Media Limited 
is not liable for any computer viruses or other material transmitted with 
or as part of this e-mail. You should employ virus checking software.
 
Guardian News & Media Limited is a member of Guardian Media Group plc. Registered 
Office: PO Box 68164, Kings Place, 90 York Way, London, N1P 2AP.  Registered 
in England Number 908396