www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 9fd243d9bd45550d5542d96ef02ab5128401287a
parent 05d2a862d5cde66de0edd744fcd782f6f152ff9c
Author: Davide P. Cervone <dpvc@union.edu>
Date:   Mon,  5 Jan 2015 10:57:07 -0500

Make NativeMML attributes work the same as toMathML ones (makes sure href/style/etc are passed on properly).

Diffstat:
Munpacked/extensions/toMathML.js | 4++--
Munpacked/jax/output/NativeMML/jax.js | 17+++++++++--------
2 files changed, 11 insertions(+), 10 deletions(-)

diff --git 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 @@ -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); },