Start a new topic

HTML5 import support

I didn't see anything off the DuoCode.Dom.HTMLLinkElement class for HTML5

import property.


Since i don't have access to the HTMLLinkElement source to add this a a "PROPERTY" like in JavaScript getElementById("link_el_ementid").import


So i created and extension for now. You guys might wanna look at a adding

support for the HTML5 import to the HTMLLinkElement.


Anyways... Here is my extension:


namespace DuoCode.Dom

{

 public static class AjaxHtmlExtensions

 {

 /// <summary>

 /// Imports a html link document

 /// </summary>

 public static HTMLDocument import(this HTMLLinkElement link)

 {

            HTMLDocument result = null;

            if (!System.String.IsNullOrEmpty(link.rel) && link.rel.Equals("import", StringComparison.OrdinalIgnoreCase)) {

                result = Js.referenceAs<dynamic>("link.import");

 }

            return result;

 }

 }

}


Sample Usage (HTML5):


 <!-- Html5 Markup -->

 <link rel="import" href="markup.html" id="markup" />



Sample Usage (CODE):


            HTMLDocument import_doc = Global.document.getElementById("markup").As<HTMLLinkElement>().import();

            if (import_doc != null) {

                HTMLElement form1 = import_doc.getElementById("form1");

                System.Console.WriteLine("Form1: " + form1.outerHTML);

                webix.message("Form1: " + form1.outerHTML);

            } else {

                webix.message(new { type = "error", text = "No Form 1 Markup Element Found", expire = 10000 });

 }



U can download 0.6.1253.0 with fixed .targets file already, or just auto via NuGet update.

The HtmlLinkElement.import will be available in next 0.7 release only, sorry.

Dont See the HtmlLinkElement.import()


Where did you add the 

public extern HTMLDocument import { get; }


OR is it not in the 0.6.1251... it will be in next release along with new DuoCode.targets update to fix missing .js file


We added the missed property, thanks.

public extern HTMLDocument import { get; }

 

Yeah... but you still gotta be able to link.import() so to you can actually get the HTMLDocument object

I think these properties are good for you:

HTMLLinkElement.rel { get; set; }

HTMLLinkElement.href { get; set; }

Correction to the webix.message error line, should be: webix.message(Js.@object(new { type = "error", text = "No Form Markup Element Found", expire = 10000 }));
Login or Signup to post a comment