HeaderView.prototype.fixWonkyLogo = function() {
var branding, logo, logoHeight;
if (theme.ltIE9) {
return;
}
logoHeight = parseInt("{{ settings.logo-height }}");
if (this.body.hasClass("alternate-index-layout")) {
branding = this.body;
logo = $(".logo-regular");
} else {
branding = this.$(".branding");
logo = this.$(".logo-retina").is(":visible") ? this.$(".logo-retina") : this.$(".logo-regular");
}
}
修改 在上面的代码段中添加
return branding.imagesLoaded((function(_this) {
return function() {
var initialAspectRatio, newAspectRatio;
initialAspectRatio = logo[0].naturalWidth / logo[0].naturalHeight;
initialAspectRatio = Math.round(initialAspectRatio * 10) / 10;
newAspectRatio = logo[0].width / logoHeight;
newAspectRatio = Math.round(newAspectRatio * 10) / 10;
if ((newAspectRatio !== initialAspectRatio) && (logo[0].height <= logoHeight)) {
return logo.css({
height: "auto"
});
} else {
return logo.css({
height: logoHeight
});
}
};
})(this));
我在Safari undefined is not an object (evaluating 'logo[0].naturalWidth')
中查看我的网站时出现此错误,但当我在Chrome中查看该网站时,一切正常,我没有错误。
Safari做什么/依赖的方式与Chrome有什么不同?谢谢!