Example #1
0
        public void NormalizeRemovesEmptyTextNodes()
        {
            var div = new HTMLDivElement();

            div.AppendChild(new HTMLAnchorElement());
            div.AppendChild(new TextNode());
            div.AppendChild(new HTMLDivElement());
            div.AppendChild(new TextNode("Hi there!"));
            div.AppendChild(new HTMLImageElement());
            div.Normalize();
            Assert.AreEqual(div.ChildNodes.Length, 4);
        }
Example #2
0
        public void NormalizeRemovesEmptyTextNodesNested()
        {
            var div = new HTMLDivElement();
            var a   = new HTMLAnchorElement();

            a.AppendChild(new TextNode());
            a.AppendChild(new TextNode("Not empty."));
            div.AppendChild(a);
            div.AppendChild(new TextNode());
            div.AppendChild(new HTMLDivElement());
            div.AppendChild(new TextNode("Certainly not empty!"));
            div.AppendChild(new HTMLImageElement());
            div.Normalize();
            Assert.AreEqual(a.ChildNodes.Length, 1);
        }
Example #3
0
        public void NormalizeMergeTextNodes()
        {
            var div = new HTMLDivElement();
            var a   = new HTMLAnchorElement();

            a.AppendChild(new TextNode());
            a.AppendChild(new TextNode("Not empty."));
            div.AppendChild(a);
            div.AppendChild(new TextNode());
            div.AppendChild(new HTMLDivElement());
            div.AppendChild(new TextNode("Certainly not empty!"));
            div.AppendChild(new TextNode("Certainly not empty!"));
            div.AppendChild(new TextNode("Certainly not empty!"));
            div.AppendChild(new TextNode("Certainly not empty!"));
            div.AppendChild(new HTMLImageElement());
            div.Normalize();
            Assert.AreEqual(div.ChildNodes.Length, 4);
        }