Browse files

Fixed: Context2d setters with invalid values ignored

  • Loading branch information...
1 parent f8ffa3f commit f866dd8883c289718c2948cfddb8b89e25821f0c @tj tj committed Feb 6, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/context2d.js
View
4 lib/context2d.js
@@ -165,6 +165,7 @@ Context2d.prototype.setTransform = function(){
*/
Context2d.prototype.__defineSetter__('fillStyle', function(val){
+ if (!val) return;
if ('CanvasGradient' == val.constructor.name
|| 'CanvasPattern' == val.constructor.name) {
this.lastFillStyle = val;
@@ -192,6 +193,7 @@ Context2d.prototype.__defineGetter__('fillStyle', function(){
*/
Context2d.prototype.__defineSetter__('strokeStyle', function(val){
+ if (!val) return;
if ('CanvasGradient' == val.constructor.name
|| 'CanvasPattern' == val.constructor.name) {
this.lastStrokeStyle = val;
@@ -221,6 +223,7 @@ Context2d.prototype.__defineGetter__('strokeStyle', function(){
*/
Context2d.prototype.__defineSetter__('font', function(val){
+ if (!val) return;
if ('string' == typeof val) {
var font;
if (font = parseFont(val)) {
@@ -252,6 +255,7 @@ Context2d.prototype.__defineGetter__('font', function(){
*/
Context2d.prototype.__defineSetter__('textBaseline', function(val){
+ if (!val) return;
var n = baselines.indexOf(val);
if (~n) {
this.lastBaseline = val;

0 comments on commit f866dd8

Please sign in to comment.