From a714a91dc60ca7155f50b106d98cb9d1a9e500d9 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Sat, 6 Dec 2014 17:36:23 -0500 Subject: [PATCH] Add a flag to Get() to look up only the inherited value, not the one from the element itself, so that toMathML() doesn't have to delete and replace the attibutes. Resolves issue #971. --- unpacked/extensions/toMathML.js | 5 ++--- unpacked/jax/element/mml/jax.js | 8 +++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/unpacked/extensions/toMathML.js b/unpacked/extensions/toMathML.js index 28135c383..49c16da1a 100644 --- a/unpacked/extensions/toMathML.js +++ b/unpacked/extensions/toMathML.js @@ -61,9 +61,8 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () { if (this.type === "mstyle") {defaults = MML.math.prototype.defaults} for (var id in defaults) {if (!skip[id] && !copy[id] && defaults.hasOwnProperty(id)) { if (this[id] != null && this[id] !== defaults[id]) { - var value = this[id]; delete this[id]; - if (this.Get(id) !== value) {attr.push(id+'="'+this.toMathMLattribute(value)+'"')} - this[id] = value; + if (this.Get(id,null,1) !== this[id]) + attr.push(id+'="'+this.toMathMLattribute(this[id])+'"'); } }} } diff --git a/unpacked/jax/element/mml/jax.js b/unpacked/jax/element/mml/jax.js index e37929acd..a6b2804cc 100644 --- a/unpacked/jax/element/mml/jax.js +++ b/unpacked/jax/element/mml/jax.js @@ -296,9 +296,11 @@ MathJax.ElementJax.mml.Augment({ while (parent && parent.notParent) {parent = parent.parent} return parent; }, - Get: function (name,nodefault) { - if (this[name] != null) {return this[name]} - if (this.attr && this.attr[name] != null) {return this.attr[name]} + Get: function (name,nodefault,noself) { + if (!noself) { + if (this[name] != null) {return this[name]} + if (this.attr && this.attr[name] != null) {return this.attr[name]} + } // FIXME: should cache these values and get from cache // (clear cache when appended to a new object?) var parent = this.Parent();