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.

This commit is contained in:
Davide P. Cervone 2014-12-06 17:36:23 -05:00
parent 142857afa2
commit a714a91dc6
2 changed files with 7 additions and 6 deletions

View File

@ -61,9 +61,8 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
if (this.type === "mstyle") {defaults = MML.math.prototype.defaults} if (this.type === "mstyle") {defaults = MML.math.prototype.defaults}
for (var id in defaults) {if (!skip[id] && !copy[id] && defaults.hasOwnProperty(id)) { for (var id in defaults) {if (!skip[id] && !copy[id] && defaults.hasOwnProperty(id)) {
if (this[id] != null && this[id] !== defaults[id]) { if (this[id] != null && this[id] !== defaults[id]) {
var value = this[id]; delete this[id]; if (this.Get(id,null,1) !== this[id])
if (this.Get(id) !== value) {attr.push(id+'="'+this.toMathMLattribute(value)+'"')} attr.push(id+'="'+this.toMathMLattribute(this[id])+'"');
this[id] = value;
} }
}} }}
} }

View File

@ -296,9 +296,11 @@ MathJax.ElementJax.mml.Augment({
while (parent && parent.notParent) {parent = parent.parent} while (parent && parent.notParent) {parent = parent.parent}
return parent; return parent;
}, },
Get: function (name,nodefault) { Get: function (name,nodefault,noself) {
if (!noself) {
if (this[name] != null) {return this[name]} if (this[name] != null) {return this[name]}
if (this.attr && this.attr[name] != null) {return this.attr[name]} if (this.attr && this.attr[name] != null) {return this.attr[name]}
}
// FIXME: should cache these values and get from cache // FIXME: should cache these values and get from cache
// (clear cache when appended to a new object?) // (clear cache when appended to a new object?)
var parent = this.Parent(); var parent = this.Parent();