Replaced prototype with regular object for AttrPlugin I hope it's for better performance
This commit is contained in:
parent
069a20430c
commit
eaf8f73b07
|
@ -22,52 +22,49 @@
|
|||
}( function (KUTE) {
|
||||
'use strict';
|
||||
|
||||
var K = window.KUTE, DOM = K.dom, PP = K.pp, unit = K.Interpolate.unit, number = K.Interpolate.number;
|
||||
|
||||
// get current attribute value
|
||||
K.gCA = function(e,a){
|
||||
return e.getAttribute(a);
|
||||
}
|
||||
var K = window.KUTE, DOM = K.dom, PP = K.pp, unit = K.Interpolate.unit, number = K.Interpolate.number, atts,
|
||||
gCA = function(e,a){ // get current attribute value
|
||||
return e.getAttribute(a);
|
||||
};
|
||||
|
||||
K.prS['attr'] = function(el,p,v){
|
||||
var f = {};
|
||||
for (var a in v){
|
||||
f[a.replace(/_+[a-z]+/,'')] = K.gCA(el,a.replace(/_+[a-z]+/,''));
|
||||
f[a.replace(/_+[a-z]+/,'')] = gCA(el,a.replace(/_+[a-z]+/,''));
|
||||
}
|
||||
return f;
|
||||
};
|
||||
// register the render attributes object
|
||||
if (!('attr' in DOM)) {
|
||||
DOM.attr = function(l,p,a,b,v) {
|
||||
for ( var o in b ){
|
||||
DOM.attr.prototype[o](l,o,a[o],b[o],v);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var ra = DOM.attr.prototype;
|
||||
|
||||
// process attributes object K.pp.attr(t[x])
|
||||
// and also register their render functions
|
||||
PP['attr'] = function(a,o){
|
||||
if (!('attr' in DOM)) {
|
||||
DOM.attr = function(l,p,a,b,v) {
|
||||
for ( var o in b ){
|
||||
DOM.attributes[o](l,o,a[o],b[o],v);
|
||||
}
|
||||
}
|
||||
atts = DOM.attributes = {}
|
||||
}
|
||||
|
||||
var ats = {}, p;
|
||||
for ( p in o ) {
|
||||
if ( /%|px/.test(o[p]) ) {
|
||||
var u = K.truD(o[p]).u, s = /%/.test(u) ? '_percent' : '_'+u;
|
||||
if (!(p+s in ra)) {
|
||||
ra[p+s] = function(l,p,a,b,v) {
|
||||
if (!(p+s in atts)) {
|
||||
atts[p+s] = function(l,p,a,b,v) {
|
||||
var _p = p.replace(s,'');
|
||||
l.setAttribute(_p, unit(a.v,b.v,b.u,v) );
|
||||
}
|
||||
}
|
||||
ats[p+s] = K.truD(o[p]);
|
||||
} else {
|
||||
if (!(p in ra)) {
|
||||
ra[p] = function(l,o,a,b,v) {
|
||||
if (!(p in atts)) {
|
||||
atts[p] = function(l,o,a,b,v) {
|
||||
l.setAttribute(o, number(a,b,v));
|
||||
}
|
||||
}
|
||||
ats[p] = o[p] * 1;
|
||||
ats[p] = parseFloat(o[p]);
|
||||
}
|
||||
}
|
||||
return ats;
|
||||
|
|
Loading…
Reference in a new issue