¡Bien! En primer lugar, esta pregunta viene de un hombre que cava demasiado profundo (y posiblemente se pierde) en el universo jQuery.Diferencia del valor, prototipo y propiedad
En mi reserch descubrí el patrón principal de la jQuery es algo como esto (Si se wellcomed corrección necesaria):
(function (window, undefined) {
jQuery = function (arg) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init(arg);
},
jQuery.fn = jQuery.prototype = {
constructor: jQuery,
init: function (selector, context, rootjQuery) {
// get the selected DOM el.
// and returns an array
},
method: function() {
doSomeThing();
return this;
},
method2: function() {
doSomeThing();
return this;,
method3: function() {
doSomeThing();
return this;
};
jQuery.fn.init.prototype = jQuery.fn;
jQuery.extend = jQuery.fn.extend = function() {
//defines the extend method
};
// extends the jQuery function and adds some static methods
jQuery.extend({
method: function() {}
})
})
Cuando $
inicia la jQuery.prototype.init
iniciados y devuelve una matriz de elementos. Pero no pude entender cómo se agrega el método jQuery como .css
o .hide
, etc. a esta matriz
obtengo los métodos estáticos. Pero no pude ver cómo regresa y la matriz de elementos con todos esos métodos.
Gracias @adnan para la edición – Lupus