jQuery 1.0.4 - New Wave Javascript(js源文件)

2019-06-03 09:49:42刘景俊

            var arg = a[i];
            if ( typeof arg == "string" ) { // Convert html string into DOM nodes
                // Trim whitespace, otherwise indexOf won't work as expected
                var s = jQuery.trim(arg), div = document.createElement("div"), wrap = [0,"",""];

                if ( !s.indexOf("<opt") ) // option or optgroup
                    wrap = [1, "<select>", "</select>"];
                else if ( !s.indexOf("<thead") || !s.indexOf("<tbody") )
                    wrap = [1, "<table>", "</table>"];
                else if ( !s.indexOf("<tr") )
                    wrap = [2, "<table>", "</table>"];    // tbody auto-inserted
                else if ( !s.indexOf("<td") || !s.indexOf("<th") )
                    wrap = [3, "<table><tbody><tr>", "</tr></tbody></table>"];

                // Go to html and back, then peel off extra wrappers
                div.innerHTML = wrap[1] + s + wrap[2];
                while ( wrap[0]-- ) div = div.firstChild;
                arg = div.childNodes;
            }