Javascript Closure and DOM Builder -


I am creating a DOM builder that I have worked successfully but now I am attempting to hand over some myths So div () -> e ("div")

This is my code:

  // Assign these objects to a namespace, the default for the window (the parent) {/ ** * creates the string of the element * @param tag * @ attribute to add the ultimate option to the element * @ best child The object of ... n to use the hair element * html string to be used with internal HTML * / var e = function (tags, options) {var html = '& lt;' + tag; var children = array Apolli (logic, [(typeoff option == = "string" 1: 2]); if (option & amp; amp; amp; option is!! == "string") {for option ( Var option) {html = = '' + + + option = '+ + option [option] +' '' '}} html + =' & gt; (different children in children) {html = = children [Child];} html + = '& lt ; / '+ Tag +' & gt; '; HTML Return; } // Shorthand for E (& lt; tag & gt;) for the tag tag does not work in this part tag = "div span strong cite em li ul ol table th tr td input form textarea" .split ( ""), I = 0; To stop EL (= i; l; tag.length; i ++) {(function (L) {// to keep EL at the root of scope [L] = function () {var args = Array.prototype. Slice.call; logic; Console.log (args); args [0] = L; // return the shorthand tag to the first logic e.apply (e, args);};}) (tag [i]); } // Appoint e to parent. E = e; })(Window);  

What is currently happening, when I call one of the works of short stories and I think what needs to be done then the AGRA array is being revised every time. Every time it is called affected Production of unit tests:

div (div (span ("content")), span ()) Expected: & lt; Div & gt; & Lt; Div & gt; & Lt; Span & gt; Content & lt; / Span & gt; & Lt; / Div & gt; & Lt; Span & gt; & Lt; / Span & gt; & Lt; / Div & gt; Result: & lt; Div & gt; & Lt; Span & gt; & Lt; / Span & gt; & Lt; / Div & gt;

(div (e ("b", e ("b", e ("b"))), duration ()) expected: & lt; Div & gt; & Lt; Div & gt; & Lt; Period & gt; & Lt; P & gt; & Lt; P & gt; & Lt; P & gt; & Lt; / B & gt; & Lt; / B & gt; & Lt; / B & gt; & Lt; / Span & gt; & Lt; Period & gt; & Lt; / Span & gt; & Lt; / Div & gt; Result:
gt; Post-Text "itemprop =" text ">

Although this does not answer your question directly,

 for  (in various tags) {  < P> is not completely correct.  tag  is an array, not an object, so its properties are not used for  (... in ...)  

 for  (var el = 0; el & lt; tags.length; el ++)  

The interpretation of this interpreter You can make a huge difference in your code ... and your algorithm co Execution.


Comments