diff --git a/unpacked/extensions/toMathML.js b/unpacked/extensions/toMathML.js index 821d8085c..ccd788ebd 100644 --- a/unpacked/extensions/toMathML.js +++ b/unpacked/extensions/toMathML.js @@ -51,14 +51,14 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () { }, toMathMLattributes: function () { - var attr = [], defaults = this.defaults; + var defaults = (this.type === "mstyle" ? MML.math.prototype.defaults : this.defaults); var names = (this.attrNames||MML.copyAttributeNames), skip = MML.skipAttributes, copy = MML.copyAttributes; + var attr = []; if (this.type === "math" && (!this.attr || !this.attr.xmlns)) {attr.push('xmlns="http://www.w3.org/1998/Math/MathML"')} if (!this.attrNames) { - 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]) { if (this.Get(id,null,1) !== this[id]) diff --git a/unpacked/jax/output/NativeMML/jax.js b/unpacked/jax/output/NativeMML/jax.js index 99e68dcb6..fcf687562 100644 --- a/unpacked/jax/output/NativeMML/jax.js +++ b/unpacked/jax/output/NativeMML/jax.js @@ -491,17 +491,18 @@ // NativeMMLattributes: function (tag) { var defaults = (this.type === "mstyle" ? MML.math.prototype.defaults : this.defaults); - var copy = (this.attrNames||MML.copyAttributeNames), skip = MML.skipAttributes; + var names = (this.attrNames||MML.copyAttributeNames), + skip = MML.skipAttributes, copy = MML.copyAttributes; if (!this.attrNames) { - for (var id in defaults) {if (!skip[id] && defaults.hasOwnProperty(id)) { - if (this[id] != null && this[id] !== defaults[id]) {tag.setAttribute(id,this.NativeMMLattribute(this[id]))} + for (var id in defaults) {if (!skip[id] && !copy[id] && defaults.hasOwnProperty(id)) { + if (this[id] != null && this[id] !== defaults[id]) + tag.setAttribute(id,this.NativeMMLattribute(this[id])); }} } - for (var i = 0, m = copy.length; i < m; i++) { - if (defaults.hasOwnProperty(copy[i])) { - var value = (this.attr||{})[copy[i]]; if (value == null) {value = this[copy[i]]} - if (value != null) {tag.setAttribute(copy[i],this.NativeMMLattribute(value))} - } + for (var i = 0, m = names.length; i < m; i++) { + if (copy[names[i]] === 1 && !defaults.hasOwnProperty(names[i])) continue; + var value = (this.attr||{})[names[i]]; if (value == null) {value = this[names[i]]} + if (value != null) {tag.setAttribute(names[i],this.NativeMMLattribute(value))} } this.NativeMMLclass(tag); },