Optimise DomElement.getPrefixValue()

This commit is contained in:
Jürg Lehni 2013-10-10 16:40:46 +02:00
parent 22e13df102
commit d158056899
2 changed files with 4 additions and 4 deletions

View file

@ -205,10 +205,10 @@ var DomElement = new function() {
*/
getPrefixValue: function(el, name) {
var value = el[name],
prefixes = ['webkit', 'moz', 'ms', 'o'],
suffix = name[0].toUpperCase() + name.substring(1);
Base.each(['webkit', 'moz', 'ms', 'o'], function(prefix) {
value = el[prefix + suffix] || value;
});
for (var i = 0; i < 4 && value == null; i++)
value = el[prefixes[i] + suffix];
return value;
}
};

View file

@ -40,7 +40,7 @@ var CanvasView = View.extend(/** @lends CanvasView# */{
// http://www.html5rocks.com/en/tutorials/canvas/hidpi/
var ratio = (window.devicePixelRatio || 1) / (DomElement.getPrefixValue(
ctx, 'backingStorePixelRatio') || 1);
// Upscale the canvas if the two ratios don't match
// Upscale the canvas if the two ratios don't match.
if (ratio > 1) {
var width = canvas.clientWidth,
height = canvas.clientHeight,