如何为我的库创建.extend()函数?

时间:2014-01-14 20:19:41

标签: javascript extend

我正在研究类似jQuery的JavaScript库。这是基本代码:

(function(){
    var package = {
        version: "0.1.0",
    },
    ZeTex = function(selector){
        // ZeTex is really a masked version of the ZeTex.fn.init object.
        return new ZeTex.fn.init(selector);
    };
    ZeTex.fn = ZeTex.prototype = {
        init: function(selector){
            if(selector){
                if(typeof slector = "object") {
                    this[0] = selector;
                } else if(typeof selector = "string") {
                    this[0] = document.querySelectorAll();
                }
                return this; 
            } else {
                return this;
            }
        }
    };
    ZeTex.fn.init.prototype = ZeTex.fn;

    ZeTex.extend = ZeTex.fn.extend = function(){
        //code
    };


    window.ZeTex = window.$ = ZeTex;
})();

如何完成.extend()功能?

谢谢。

0 个答案:

没有答案