/// <summary>
        /// detaches the node from dom; should be renamed to Orphanize
        /// </summary>
        //[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)
        //, ObsoleteAttribute("", false)
        //]
        //public static T Dispose<T>(this T e)
        //    where T : INode
        //{
        //    return e.Orphanize();
        //}



        public static void Clear(this INodeConvertible <IHTMLElement> ee)
        {
            var e = ee.AsNode();

            var p = e.firstChild;

            while (p != null)
            {
                e.removeChild(p);
                p = e.firstChild;
            }
        }
        public static void ReplaceWith(this INodeConvertible <IHTMLElement> ee, INodeConvertible <IHTMLElement> evalue)
        {
            // unless its from vb
            // then it could be just a number coming in...
            // Z:\jsc.svn\examples\javascript\vb\LEST97\LEST97\Application.vb

            var e     = ee.AsNode();
            var value = evalue.AsNode();

            // http://msdn.microsoft.com/en-us/library/system.xml.linq.xnode.replacewith.aspx

            if (e.parentNode == null)
            {
                return;
            }

            // tested by
            // X:\jsc.svn\examples\javascript\appengine\RemainingMillisExperiment\RemainingMillisExperiment\Application.cs
            // X:\jsc.svn\examples\javascript\svg\SVGNavigationTiming\SVGNavigationTiming\Application.cs


            var old = e.attributes.Select(x => new { x.name, x.value }).ToArray();

            var old_id = ((IHTMLElement)e).id;

            e.parentNode.replaceChild(value, e);


            // merge attributes
            foreach (var item in old)
            {
                if (!value.hasAttribute(item.name))
                {
                    value.setAttribute(item.name, item.value);
                }
            }

            if (!string.IsNullOrEmpty(old_id))
            {
                //((IHTMLElement)value).id = old_id;

                // we just swapped out id's. make the old element forget its id
                e.id = "";
            }
        }
Example #3
0
 public static IEnumerable <IHTMLImage> ImageElements(this INodeConvertible <IHTMLElement> e)
 {
     return(e.AsNode().querySelectorAll(IHTMLElement.HTMLElementEnum.img).Select(k => (IHTMLImage)k));
 }
Example #4
0
 public static IHTMLCanvas AsCanvas(this INodeConvertible <IHTMLDiv> l)
 {
     // X:\jsc.svn\examples\javascript\canvas\AsCanvasExperiment\AsCanvasExperiment\Application.cs
     return((IHTMLCanvas)l.AsNode());
 }
Example #5
0
 public static IEnumerable <IHTMLAudio> AudioElements(this INodeConvertible <IHTMLElement> e)
 {
     return(e.AsNode().querySelectorAll(IHTMLElement.HTMLElementEnum.audio).Select(k => (IHTMLAudio)k));
 }