/// <summary>Creates a new element in this document. You'll need to parent it to something. /// E.g. with thisDocument.body.appendChild(...). Alternative to innerHTML and appendInnerHTML.</summary> /// <param name='tag'>The tag, e.g. <div id='myNewElement' .. ></param> public Element createElement(string tag) { Element result = new Element(tag, body); result.OnChildrenLoaded(); result.GetHandler().OnTagLoaded(); return(result); }
public override void OnChildrenLoaded() { // Grab the summary element: Element summary = Element.getElementByTagName("summary"); if (summary != null) { // Pop it out: summary.parentNode.removeChild(summary); // Grab the summary tag handler: SummaryTag summaryTag = (SummaryTag)summary.GetHandler(); // Set this details element to it: summaryTag.Details = Element; // Insert it as a child alongside this details tag: Element.parentNode.appendChild(summary); // We know for sure that summary is the last element, and this details // tag is immediately after it. Their the wrong way around, so simply flip them over: List <Element> children = Element.parentNode.childNodes; // Whats the index of the last child? int last = children.Count - 1; // The last one is now Element: children[last] = Element; // And the one before it is summary: children[last - 1] = summary; } // And handle style/ other defaults: base.OnTagLoaded(); }
/// <summary>Creates a new element in this document. You'll need to parent it to something. /// E.g. with thisDocument.body.appendChild(...). Alternative to innerHTML and appendInnerHTML.</summary> /// <param name='tag'>The tag, e.g. <div id='myNewElement' .. ></param> public Element createElement(string tag){ Element result=new Element(tag,body); result.OnChildrenLoaded(); result.GetHandler().OnTagLoaded(); return result; }