PDA

View Full Version : [FIXED] [4.2.x] Ext.util.Positionable#calculateAnchorXY - operator precedence not considered



makana
13 Oct 2013, 11:32 PM
Hello guys,

I stumbled upon a small issue in Ext.util.Positionable#calculateAnchorXY where some braces are missing and so the operator precedence leads to a wrong result if you pass the "mySize" parameter to "getAnchorXY" method.



Ext4.define('Ext.override.util.Positionable', {
override: 'Ext.util.Positionable',
/**
* @inheritdoc
*/
calculateAnchorXY: function(anchor, extraX, extraY, mySize)
{
var me = this,
el = me.el,
doc = document,
isViewport = el.dom == doc.body || el.dom == doc,
round = Math.round,
xy, myWidth, myHeight;

anchor = (anchor || "tl").toLowerCase();
mySize = mySize || {};

// Bei diesen beiden Zeilen fehlten die Klammern.
// Leider keine andere Chance, als die komplette Methode hier hinzukopieren.
myWidth = mySize.width || (isViewport ? Ext4.Element.getViewWidth() : me.getWidth());
myHeight = mySize.height || (isViewport ? Ext4.Element.getViewHeight() : me.getHeight());

switch (anchor)
{
case 'tl': xy = [0, 0];
break;
case 'bl': xy = [0, myHeight];
break;
case 'tr': xy = [myWidth, 0];
break;
case 'c': xy = [round(myWidth * 0.5), round(myHeight * 0.5)];
break;
case 't': xy = [round(myWidth * 0.5), 0];
break;
case 'l': xy = [0, round(myHeight * 0.5)];
break;
case 'r': xy = [myWidth, round(myHeight * 0.5)];
break;
case 'b': xy = [round(myWidth * 0.5), myHeight];
break;
case 'tc': xy = [round(myWidth * 0.5), 0];
break;
case 'bc': xy = [round(myWidth * 0.5), myHeight];
break;
case 'br': xy = [myWidth, myHeight];
}
return [xy[0] + extraX, xy[1] + extraY];
}
}, function() {
// Ext.util.Positionable ist als Mixin in Ext.dom.Element und Ext.AbstractComponent drin.
// Diese also auch überschreiben.
Ext4.override(Ext4.dom.Element, {
calculateAnchorXY: this.prototype.calculateAnchorXY
});
Ext4.override(Ext4.AbstractComponent, {
calculateAnchorXY: this.prototype.calculateAnchorXY
});
});


Regards,
makana

mitchellsimoens
14 Oct 2013, 1:56 PM
What version are you using?

nevermind, see it in the title.

mitchellsimoens
14 Oct 2013, 1:56 PM
Thanks for the report! I have opened a bug in our bug tracker.