マイモジュールロードシステムv 21

32669 ワード

上stackoverflowはいつも利益があって、昨日opera 12の前に1つの比較的に致命的なBUGを発見して、トリガの条件はscript.onreadystatechange = script.onload=function(){}なのでmass,jQuery,seajs,labjs,headjs,controljsも含めて中招しました.私たちは連写回調による血事件と呼ぶことができる.これは本文で詳しく説明します.
このリリースの2番目の改良は、IE 6の自閉合baseラベル回避の問題です.以前はbaseラベルが存在するかどうかにかかわらず、すべてのブラウザがheadラベルの最初のサブノードの前に挿入されていました.しかし、このような逆順序は、後挿入の先解析を引き起こす可能性がある.従って、IE 6は、baseタグが存在する場合、自己閉鎖されているかどうかにかかわらず、その前に挿入されると、順次挿入が保証されるように処理される.他のブラウザではheadを使用します.appendChild(script).
本バージョンの第3の改良はFF 3である.6 documentはサポートされていません.readyState問題、これはdomReadyに使用されます.以前はDOCを先行判定していた.readyState=="complete"ですが、FFにはこれがなく、毎回DOMContentLoadedブランチに入ります.しかし、DOMContentLoadedイベントは一度だけトリガーされ、domReady以降はこのブランチは機能しません.ソリューションlabjsのソースコードから読みました.

	/* The following "hack" was suggested by Andrea Giammarchi and adapted from: http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html
	   NOTE: this hack only operates in FF and then only in versions where document.readyState is not present (FF < 3.6?).
	   
	   The hack essentially "patches" the **page** that LABjs is loaded onto so that it has a proper conforming document.readyState, so that if a script which does 
	   proper and safe dom-ready detection is loaded onto a page, after dom-ready has passed, it will still be able to detect this state, by inspecting the now hacked 
	   document.readyState property. The loaded script in question can then immediately trigger any queued code executions that were waiting for the DOM to be ready. 
	   For instance, jQuery 1.4+ has been patched to take advantage of document.readyState, which is enabled by this hack. But 1.3.2 and before are **not** safe or 
	   fixed by this hack, and should therefore **not** be lazy-loaded by script loader tools such as LABjs.
	*/ 
	(function(addEvent,domLoaded,handler){
		if (document.readyState == null && document[addEvent]){
			document.readyState = "loading";
			document[addEvent](domLoaded,handler = function(){
				document.removeEventListener(domLoaded,handler,false);
				document.readyState = "complete";
			},false);
		}
	})("addEventListener","DOMContentLoaded");

4つ目の改良は、フレームワークの最初の3つのセミコロンの回帰です!これは、スクリプトをマージするときに使用します.
さあ、最初の問題に戻りましょう.私たちの肉類です.scriptロードモジュールの使用は、イベントコールバックを提供し、ロード状況全体を把握するために推奨されています.IE 6-8はonreadystatechangeイベントを使用し、IE 9-10はonloadをサポートし始め、他の標準ブラウザはonloadをサポートしているが、operaは奇抜で、onloadとonreadystatechangeはいずれもサポートされており、scriptにもreadyStateプロパティがある.operaがパクリしても構わないが、BUGを写す.
次のスクリプトを見て、初めてロードしたとき、opera 9.64 interactive,loadedをポップアップします.その後、このページを閉じて開くと、loaded、loaded(ブラウザキャッシュの原因と推定)がポップアップされ、改善されないに違いありません.opera 10のようなランダムなバージョンを抽出する.52、新しいJSファイルをロードして、初めてloaded、loadedをポップアップします.幸いopera 12.12、onreadystatechangeはサポートされていません.一方、IE 6-10は常にloading、loadedをポップアップします.

window.onload = function(){
    var script = document.createElement("script");
    var array = []
    script.onreadystatechange = function(){
        array.push(this.readyState);
    }
    script.src = "jquery.js"// Opera 9.64
    document.body.appendChild(script);
    setTimeout(function(){
        alert(array)
    },2000)
}

言い換えれば、operaがJSをロードしない前にユーザコールバックを実行すると、エラーが発生します.解决策は连写しないで、そしてコールバックの中でIEだけに対してreadyState判定を行います!以下は改良されたloadJS関数です.


    function loadJS( url ){
        var node = DOC.createElement("script")//, IE = node.uniqueID
        node.className = moduleClass;
        node[W3C ? "onload" : "onreadystatechange"] = function(){
            if(W3C || /loaded|complete/i.test(node.readyState) ){
                //mass Framework  _checkFail         
                var factory = parsings.pop() ;
                factory &&  factory.delay(node.src)
                if( checkFail(node) ){
                    $.log("      "+node.src, 7);
                }
            }
        }
        node.onerror = function(){
            checkFail(node, true)
        }
        node.src = url 
   
            head.appendChild(node)

        $.log("      "+node.src, 7)
    }

基本的にはそうです.mass Frameworkの多くのアイデアはいつも世界の前に走って、互換性は大きくて漏れがなくて、試用を歓迎します!

;;;(function( global, DOC ){
    var $$ = global.$//        
    var rmakeid = /(#.+|\W)/g;
    var NsKey = DOC.URL.replace( rmakeid,"")
    var NsVal = global[ NsKey ];//      
    var W3C   = DOC.dispatchEvent //w3c    
    var html  = DOC.documentElement;
    var head  = DOC.head || DOC.getElementsByTagName( "head" )[0]
    var base = head.getElementsByTagName("base")[0];
    var loadings = [];//          
    var parsings = []; //      ID factory       (      , parse script    onload)
    var mass = 1;//        
    var postfix = "";//      
    var cbi = 1e5 ; //           
    var all = "lang_fix,lang,support,class,flow,query,data,node,attr,css_fix,css,event_fix,event,ajax,fx"
    var moduleClass = "mass" + -(new Date());
    var class2type = {
        "[object HTMLDocument]"   : "Document",
        "[object HTMLCollection]" : "NodeList",
        "[object StaticNodeList]" : "NodeList",
        "[object IXMLDOMNodeList]": "NodeList",
        "[object DOMWindow]"      : "Window"  ,
        "[object global]"         : "Window"  ,
        "null"                    : "Null"    ,
        "NaN"                     : "NaN"     ,
        "undefined"               : "Undefined"
    }
    var toString = class2type.toString, basepath
    function $( expr, context ){//      
        if( $.type( expr,"Function" ) ){ //   safari ,typeof nodeList    function,      $.type
            return  $.require( all+",ready", expr );
        }else{
            if( !$.fn )
                throw "node module is required!"
            return new $.fn.init( expr, context );
        }
    }
    //     
    if( typeof NsVal !== "function"){
        NsVal = $;//        
        NsVal.uuid = 1;
    }
    if(NsVal.mass !== mass  ){
        NsVal[ mass ] = $;//                       
        if(NsVal.mass || ($$ && $$.mass == null)) {
            postfix = ( mass + "" ).replace(/\D/g, "" ) ;//          
        }
    }else{
        return;
    }
    /**
     *   ,           
     * @param {Object} receiver    
     * @param {Object} supplier    
     * @return  {Object}     
     */
    var has = Object.prototype.hasOwnProperty
    function mix( receiver, supplier ){
        var args = Array.apply([], arguments ),i = 1, key,//         ,          
        ride = typeof args[args.length - 1] == "boolean" ? args.pop() : true;
        if(args.length === 1){//  $.mix(hash)   
            receiver = !this.window ? this : {} ;
            i = 0;
        }
        while((supplier = args[i++])){
            for ( key in supplier ) {//      ,        
                if ( has.call(supplier,key) && (ride || !(key in receiver))) {
                    receiver[ key ] = supplier[ key ];
                }
            }
        }
        return receiver;
    }

    mix( $, {//               
        html:  html,
        head:  head,
        mix:   mix,
        rword: /[^, ]+/g,
        mass:  mass,//               ,     
        "@bind": W3C ? "addEventListener" : "attachEvent",
        //       window ,      ,        name String       
        exports: function( name ) {
            $$ && ( global.$ = $$ );//    
            name = name || $.config.nick;//           
            $.config.nick = name;
            global[ NsKey ] = NsVal;
            return global[ name ]  = this;
        },
        /**
         *    
         * @param {ArrayLike} nodes          
         * @param {Number} start   。           。     ,     
         * @param {Number} end    。         
         * @return {Array}
         */
        slice: function ( nodes, start, end ) {
            var ret = [], n = nodes.length;
            if(end === void 0 || typeof end == "number" && isFinite(end)){
                start = parseInt(start,10) || 0;
                end = end == void 0 ? n : parseInt(end, 10);
                if(start < 0){
                    start += n;
                }
                if(end > n){
                    end = n;
                }
                if(end < 0){
                    end += n;
                }
                for (var i = start; i < end; ++i) {
                    ret[i - start] = nodes[i];
                }
            }
            return ret;
        },
        /**
         *          (        )        (        )
         * @param {Any} obj       
         * @param {String} str   ,      
         * @return {String|Boolean}
         */
        type: function ( obj, str ){
            var result = class2type[ (obj == null || obj !== obj ) ? obj :  toString.call( obj ) ] || obj.nodeName || "#";
            if( result.charAt(0) === "#" ){//              , window.opera
                //  IE678 window == document true,document == window   false     
                if( obj == obj.document && obj.document != obj ){
                    result = "Window"; //       
                }else if( obj.nodeType === 9 ) {
                    result = "Document";//       
                }else if( obj.callee ){
                    result = "Arguments";//       
                }else if( isFinite( obj.length ) && obj.item ){
                    result = "NodeList"; //      
                }else{
                    result = toString.call( obj ).slice( 8, -1 );
                }
            }
            if( str ){
                return str === result;
            }
            return result;
        },
        //$.log(str, showInPage=true, 5 )
        //level Number,                 。0   ,         ,
        //7              。       level <= $.config.level。
        //  $.colre.level   9。   level      。
        //0 EMERGENCY     ,    
        //1 ALERT             
        //2 CRITICAL     
        //3 ERROR   
        //4 WARNING   
        //5 NOTICE            
        //6 INFO        
        //7 DEBUG     
        log: function (str){
            var show = true, page = false
            for(var i = 1 ; i < arguments.length; i++){
                var el = arguments[i]
                if(typeof el == "number"){
                    show = el <=  $.config.level
                }else if(el === true){
                    page = true;
                }
            }
            if(show){
                if( page === true ){
                    $.require( "ready", function(){
                        var div =  DOC.createElement( "pre" );
                        div.className = "mass_sys_log";
                        div.innerHTML = str +"";//      
                        DOC.body.appendChild(div);
                    });
                }else if( global.console ){
                    global.console.log( str );
                }
            }
            return str
        },
        //                 ,        ,    ,    
        getUid: global.getComputedStyle ? function( obj ){//IE9+,     
            return obj.uniqueNumber || ( obj.uniqueNumber = NsVal.uuid++ );
        }: function( obj ){
            if(obj.nodeType !== 1){//       ,    ,window  
                return obj.uniqueNumber || ( obj.uniqueNumber = NsVal.uuid++ );
            }// :  IE XML      el.xxx = yyy        
            var uid = obj.getAttribute("uniqueNumber");
            if ( !uid ){
                uid = NsVal.uuid++;
                obj.setAttribute( "uniqueNumber", uid );
            }
            return +uid;//      
        },
        /**
         *          ,       
         * @param {Array|String} array       ,  ","     
         * @param {Number} val   ,   1
         * @return {Object}
         */
        oneObject : function( array, val ){
            if( typeof array == "string" ){
                array = array.match( $.rword ) || [];
            }
            var result = {}, value = val !== void 0 ? val :1;
            for(var i = 0, n = array.length; i < n; i++){
                result[ array[i] ] = value;
            }
            return result;
        },
        config: function( settings ) {
            var kernel  = $.config;
            for ( var p in settings ) {
                if (!settings.hasOwnProperty( p ))
                    continue
                var prev = kernel[ p ];
                var curr = settings[ p ];
                if (prev && p === "alias") {
                    for (var c in curr) {
                        if (curr.hasOwnProperty( c )) {
                            var prevValue = prev[ c ];
                            var currValue = curr[ c ];
                            if( prevValue && prev !== curr ){
                                throw new Error(c + "     ")
                            }
                            prev[ c ] = currValue;
                        }
                    }
                } else {
                    kernel[ p ] = curr;
                }
            }
            return this
        }
    });
    (function(scripts, cur){
        cur = scripts[ scripts.length - 1 ];
        var url = cur.hasAttribute ?  cur.src : cur.getAttribute( "src", 4 );
        url = url.replace(/[?#].*/, "");
        var a = cur.getAttribute("debug");
        var b = cur.getAttribute("storage");
        var kernel = $.config;
        kernel.debug = a == "true" || a == "1";
        kernel.storage = b == "true"|| b == "1";
        basepath =  kernel.base = url.substr( 0, url.lastIndexOf("/") ) +"/";
        kernel.nick = cur.getAttribute("nick") || "$";
        kernel.erase = cur.getAttribute("erase") || "erase";
        kernel.alias = {};
        kernel.level = 9;

    })(DOC.getElementsByTagName( "script" ));
    $.noop = $.error = function(){};

    "Boolean,Number,String,Function,Array,Date,RegExp,Window,Document,Arguments,NodeList".replace( $.rword, function( name ){
        class2type[ "[object " + name + "]" ] = name;
    });

    function parseURL(url, parent, ret){
        //[]  ,     -   ,    /^[-a-z0-9_$]{2,}$/i   /^[a-z0-9_-$]{2,}
        //        ;             
        if( /^(mass|ready)$/.test(url)){//    ready   
            return [url, "js"];
        }
        if(/^[-a-z0-9_$]{2,}$/i.test(url) && $.config.alias[url] ){
            ret = $.config.alias[url];
        }else{
            parent = parent.substr( 0, parent.lastIndexOf('/') )
            if(/^(\w+)(\d)?:.*/.test(url)){  //          
                ret = url
            }else {
                var tmp = url.charAt(0);
                if( tmp !== "." && tmp != "/"){  //      
                    ret = basepath + url;
                }else if(url.slice(0,2) == "./"){ //       
                    ret = parent + url.substr(1);
                }else if( url.slice(0,2) == ".."){ //      
                    var arr = parent.replace(/\/$/,"").split("/");
                    tmp = url.replace(/\.\.\//g,function(){
                        arr.pop();
                        return "";
                    });
                    ret = arr.join("/")+"/"+tmp;
                }else if(tmp == "/"){
                    ret = parent  + url
                }else{
                    throw new Error("         : "+url)
                }
            }
        }
        var ext = "js";
        tmp = ret.replace(/[?#].*/, "");
        if(/\.(\w+)$/.test( tmp )){
            ext = RegExp.$1;
        }
        if( ext!="css" &&tmp == ret && !/\.js$/.test(ret)){//          .js
            ret += ".js";
        }
        return [ret, ext];
    }
  
    $.mix({
        //    (   )
        bind: W3C ? function( el, type, fn, phase ){
            el.addEventListener( type, fn, !!phase );
            return fn;
        } : function( el, type, fn ){
            el.attachEvent && el.attachEvent( "on"+type, fn );
            return fn;
        },
        unbind: W3C ? function( el, type, fn, phase ){
            el.removeEventListener( type, fn || $.noop, !!phase );
        } : function( el, type, fn ){
            if ( el.detachEvent ) {
                el.detachEvent( "on" + type, fn || $.noop );
            }
        },
        //               
        erase : function( id, v ){
            if(id == void 0){
                Storage.clear();
            }else{
                var old = Storage.getItem( id+"_version" );
                if(old && (!v || v > Number(old)) ){
                    Storage.removeItem( id );
                    Storage.removeItem( id+"_deps" );
                    Storage.removeItem( id+"_parent" );
                    Storage.removeItem( id+"_version" );
                }
            }
        }
    });
    //================================localStorage===============================
    var Storage = $.oneObject("setItem,getItem,removeItem,clear",$.noop);
    if( global.localStorage){
        Storage = localStorage; 
    }else  if( html.addBehavior){
        html.addBehavior('#default#userData');
        html.save("massdata");
        //https://github.com/marcuswestin/store.js/issues/40#issuecomment-4617842
        // IE67        ,       ,   throwed an This name may not contain the '~' character: _key-->~<--
        var rstoragekey = new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]", "g");
        function curry(fn) {
            return function(a, b) {
                html.load("massdata");
                a = String(a).replace(rstoragekey, function(w){
                    return w.charCodeAt(0);
                });
                var result = fn( a, b );
                html.save("massdata");
                return result
            }
        }
        Storage = {
            setItem : curry(function(key, val){
                html.setAttribute(key, val);
            }),
            getItem: curry(function(key){
                return html.getAttribute(key);
            }),
            removeItem: curry(function(key){
                html.removeAttribute(key);
            }),
            clear: function(){
                var attributes = html.XMLDocument.documentElement.attributes
                for (var i=0, attr; attr=attributes[i]; i++) {
                    html.removeAttribute(attr.name)
                }
            }
        }
    }
    var rerase = new RegExp("(?:^| )" + $.config.erase + "(?:(?:=([^;]*))|;|$)")
    var match = String(DOC.cookie).match( rerase );
    //        cookie  ,       ,      URL,     (       )
    if(match && match[1]){
        try{
            var obj = eval("0,"+match[1]);
            for(var i in obj){//$.erase                   
                $.erase(i, obj[i])
            }
        }catch(e){}
    }

    //============================    ===========================
    var modules = $.modules =  {
        ready:{ },
        mass: {
            state: 2,
            exports: $
        }
    };
    function getCurrentScript(){
        if(DOC.currentScript){
            return DOC.currentScript.src
        }
        var nodes = DOC.getElementsByTagName("script")
        for (var i = 0, node; node = nodes[i++];) {
            if (!node.pass && node.className == moduleClass && node.readyState === "interactive") {
                return  node.pass = node.src;
            }
        }
    }
    //          
    function checkCycle( deps, nick ){
        for(var id in deps){
            if( deps[id] == "    " && modules[id].state != 2 &&( id == nick || checkCycle(modules[id].deps, nick))){
                return true;
            }
        }
    }
    //   JS             ,      
    function checkDeps(){
        loop:
        for ( var i = loadings.length, id; id = loadings[ --i ]; ) {
            var obj = modules[ id ], deps = obj.deps;
            for( var key in deps ){
                if( deps.hasOwnProperty( key ) && modules[ key ].state != 2 ){
                    continue loop;
                }
            }
            //  deps                 2
            if( obj.state != 2){
                loadings.splice( i, 1 );//        ,   IE DOM          ,      
                fireFactory( obj.id, obj.args, obj.factory );
                checkDeps();
            }
        }
    }
    function checkFail( node, error ){
        var id = node.src;
        node.onload = node.onreadystatechange = node.onerror = null;
        if( error || !modules[ id ].state ){
            //  , IE  !modules[ id ].state       ,           
            setTimeout(function(){
                head.removeChild(node)
            }, error ? 0 : 1000 );
            $.log("   "+ id +"   ", 7);
        }else{
            return true;
        }
    }
    function loadJS( url ){
        var node = DOC.createElement("script")//, IE = node.uniqueID
        node.className = moduleClass;
        node[W3C ? "onload" : "onreadystatechange"] = function(){
            if(W3C || /loaded|complete/i.test(node.readyState) ){
                //mass Framework  _checkFail         ,       ,  DOM0     IE6 GC  
                var factory = parsings.pop() ;
                factory &&  factory.delay(node.src)
                if( checkFail(node) ){
                    $.log("      "+node.src, 7);
                }
            }
        }
        node.onerror = function(){
            checkFail(node, true)
        }
        node.src = url 

            head.appendChild(node)

        $.log("      "+node.src, 7)
    }
    function loadCSS(url){
        var id = url.replace(rmakeid,"");
        if (DOC.getElementById(id))
            return
        var node     =  DOC.createElement("link");
        node.rel     = "stylesheet";
        node.href    = url;
        node.id      = id;
        head.insertBefore( node, head.firstChild );
    }
    function loadStorage( id ){
        var factory =  Storage.getItem( id );
        if( $.config.storage && factory && !modules[id]){
            var parent = Storage.getItem(id+"_parent");
            var deps = Storage.getItem(id+"_deps");
            deps = deps ?  deps.match( $.rword ) : "";
            modules[ id ] ={
                id: id,
                parent: parent,
                exports: {},
                state: 1
            };
            require(deps, Function("return "+ factory )(), id) //0,1,2 --> 1,2,0
        }
    }

    //    (    ,    ,          )
    window.require = $.require = function( list, factory, parent ){
        var deps = {},  //             2
        args = [],      //               
        dn = 0,         //         
        cn = 0,         //         
        id = parent || "cb"+ ( cbi++ ).toString(32);
        parent = parent || basepath
        String(list).replace( $.rword, function(el){
            var array = parseURL(el, parent ),  url = array[0];
            if(array[1] == "js"){
                dn++
                loadStorage( id )
                if( !modules[ url ]  ){
                    modules[ url ] = {
                        id: url,
                        parent: parent,
                        exports: {}
                    };
                    loadJS( url );
                }else if( modules[ url ].state === 2 ){
                    cn++;
                }
                if( !deps[ url ] ){
                    args.push( url );
                    deps[ url ] = "    ";//  
                }
            }else if(array[1] === "css"){
                loadCSS( url );
            }
        });
        //          
        modules[id] = {
            id: id,
            factory: factory,
            deps: deps,
            args: args,
            state: 1
        }
        if( dn === cn ){//              
            fireFactory( id, args, factory );//      
            checkDeps();
            return
        }
        //            _checkDeps  
        loadings.unshift( id );
    }
    //    
    var rcomment =  /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g
    window.define = $.define = function( id, deps, factory ){//   ,    ,    
        var args = Array.apply([],arguments), _id
        if(typeof id == "string"){
            _id = args.shift();
        }
        if( typeof args[0] === "boolean" ){//      ,              
            if( args[0] ){
                return;
            }
            args.shift()
        }
        if(typeof args[0] == "function"){
            args.unshift([]);
        }//            ID,            script   src    ID
        // getCurrentScript    IE6-10,FF4+  ,    onload+delay    
        id = modules[id] && modules[id].state == 2 ? _id : getCurrentScript();
        factory = args[1];
        factory.id = _id;//    
        factory.delay = function( id ){
            args.push( id );
            if( checkCycle(modules[id].deps, id)){
                throw new Error( id +"                ")
            }
            if( $.config.storage && !Storage.getItem( id ) ){
                Storage.setItem( id, factory.toString().replace(rcomment,""));
                Storage.setItem( id+"_deps", args[0]+"");
                Storage.setItem( id+"_parent",  id);
                Storage.setItem( id+"_version", new Date - 0);
            }
            delete factory.delay;//    
            require.apply(null, args); //0,1,2 --> 1,2,0
        }
        if(id ){
            factory.delay(id,args)
        }else{//    
            parsings.push( factory )
        }
    }
    $.require.amd = modules
    
    // returns                 ,  factory,        
    function fireFactory( id, deps, factory ){
        for ( var i = 0, array = [], d; d = deps[i++]; ) {
            array.push( modules[ d ].exports );
        }
        var module = Object( modules[id] ), ret;
        ret =  factory.apply(global, array);
        module.state = 2;
        if( ret !== void 0 ){
            modules[ id ].exports = ret
        }
        return ret;
    }
    all.replace($.rword,function(a){
        $.config.alias[ "$"+a ] = basepath + a + ".js";
    });
    //domReady  
    var readyFn, ready =  W3C ? "DOMContentLoaded" : "readystatechange" ;
    function fireReady(){
        modules.ready.state = 2;
        checkDeps();
        if( readyFn ){
            $.unbind( DOC, ready, readyFn );
        }
        fireReady = $.noop;//    ,  IE9    _checkDeps
    };
    function doScrollCheck() {
        try {
            html.doScroll( "left" ) ;
            fireReady();
        } catch(e) {
            setTimeout( doScrollCheck, 31 );
        }
    };
    // firefox3.6  ,   readyState  
    //http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html
    if(DOC.readyState == null){
        DOC.readyState = "loading";
        var readyState = true;
    }
    if ( DOC.readyState === "complete" ) {
        fireReady();//   domReady    
    }else {
        $.bind( DOC, ready, readyFn = function(){
            if ( W3C || DOC.readyState === "complete" ){
                fireReady();
                if(readyState){//IE     DOC.readyState
                    DOC.readyState  = "complete";
                }
            }
        });
        if( html.doScroll && self.eval === parent.eval)
            doScrollCheck();
    }

    global.VBArray && ("abbr,article,aside,audio,bdi,canvas,data,datalist,details,figcaption,figure,footer," +
        "header,hgroup,mark,meter,nav,output,progress,section,summary,time,video").replace( $.rword, function( tag ){
        DOC.createElement(tag);
    });

    //https://developer.mozilla.org/en/DOM/window.onpopstate
    $.bind( global, "popstate", function(){
        NsKey = DOC.URL.replace(rmakeid,"");
        $.exports();
    });
    $.exports( $.config.nick +  postfix );//             
/*combine modules*/

})( self, self.document );//     VS        ,    this  self window

フレームアドレス