<div>A div</div>
<button>Get "blah" from the div</button>
<button>Set "blah" to "hello"</button>
<button>Set "blah" to 86</button>
<button>Remove "blah" from the div</button>
<p>The "blah" value of this div is <span>?</span></p>
<button>Get "blah" from the div</button>
<button>Set "blah" to "hello"</button>
<button>Set "blah" to 86</button>
<button>Remove "blah" from the div</button>
<p>The "blah" value of this div is <span>?</span></p>
2016-10-14
我靠,老师你这样弄“The jQuery.data() method allows us to attach data of any type to DOM elements in a way that is safe from circular references and therefore from memory leaks. We can set several distinct values for a single element and retrieve them later:”,乍一看,会死人的
2016-10-14
self = {
add: function(fn) {
var start = list.length;
list.push(fn)
if (memory) {
firingStart = start; //获取最后一值
_fire();
}
},
fire: function(args) {
if (list) {
memory=[this,arguments];
_fire(args)
}
}
}
add: function(fn) {
var start = list.length;
list.push(fn)
if (memory) {
firingStart = start; //获取最后一值
_fire();
}
},
fire: function(args) {
if (list) {
memory=[this,arguments];
_fire(args)
}
}
}
2016-10-14
新版设计改了 function _fire() {
memory = options === 'memory' && memory;
firingIndex = firingStart || 0;
firingStart = 0;
firingLength = list.length;
for (; list && firingIndex < firingLength; firingIndex++) {
list[firingIndex].apply(memory[0],memory[1]);
}
}
memory = options === 'memory' && memory;
firingIndex = firingStart || 0;
firingStart = 0;
firingLength = list.length;
for (; list && firingIndex < firingLength; firingIndex++) {
list[firingIndex].apply(memory[0],memory[1]);
}
}
2016-10-14