diff --git a/src/item/Item.js b/src/item/Item.js index 7735930f..93a8652c 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -164,10 +164,14 @@ var Item = Base.extend(Callback, /** @lends Item# */{ function serialize(fields) { for (var key in fields) { var value = that[key]; - if (!Base.equals(value, fields[key])) + // Allow returned values to mark themselves as default through + // the "hidden" _default property. See Style#getLeading() + if (!(value && value._default) + && !Base.equals(value, fields[key])) { props[key] = Base.serialize(value, options, // Do not use compact mode for data key !== 'data', dictionary); + } } } diff --git a/src/style/Style.js b/src/style/Style.js index ffff0393..6d72394d 100644 --- a/src/style/Style.js +++ b/src/style/Style.js @@ -238,7 +238,13 @@ var Style = Base.extend(new function() { getLeading: function getLeading() { // Override leading to return fontSize * 1.2 by default. var leading = getLeading.base.call(this); - return leading != null ? leading : this.getFontSize() * 1.2; + if (leading == null) { + // Box default leading in a Number, and mark it as default, for + // serialization. + leading = new Number(this.getFontSize() * 1.2); + leading._default = true; + } + return leading; }, getFontStyle: function() {