Add HTMLCSS.parentNode() that returns a span's parentNode, skipping over <a> tags. Resolves issue #364.
This commit is contained in:
parent
9178a9af0e
commit
9752fd6e11
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
MathJax.OutputJax["HTML-CSS"] = MathJax.OutputJax({
|
MathJax.OutputJax["HTML-CSS"] = MathJax.OutputJax({
|
||||||
id: "HTML-CSS",
|
id: "HTML-CSS",
|
||||||
version: "2.1.2",
|
version: "2.1.3",
|
||||||
directory: MathJax.OutputJax.directory + "/HTML-CSS",
|
directory: MathJax.OutputJax.directory + "/HTML-CSS",
|
||||||
extensionDir: MathJax.OutputJax.extensionDir + "/HTML-CSS",
|
extensionDir: MathJax.OutputJax.extensionDir + "/HTML-CSS",
|
||||||
autoloadDir: MathJax.OutputJax.directory + "/HTML-CSS/autoload",
|
autoloadDir: MathJax.OutputJax.directory + "/HTML-CSS/autoload",
|
||||||
|
|
|
@ -760,15 +760,15 @@
|
||||||
parent.bbox = this.Measured(span,parent).bbox;
|
parent.bbox = this.Measured(span,parent).bbox;
|
||||||
},
|
},
|
||||||
MeasureSpans: function (SPANS) {
|
MeasureSpans: function (SPANS) {
|
||||||
var spans = [], span, i, m, bbox, start, end, W;
|
var spans = [], span, i, m, bbox, start, end, W, parent;
|
||||||
//
|
//
|
||||||
// Insert the needed markers
|
// Insert the needed markers
|
||||||
//
|
//
|
||||||
for (i = 0, m = SPANS.length; i < m; i++) {
|
for (i = 0, m = SPANS.length; i < m; i++) {
|
||||||
span = SPANS[i]; if (!span) continue;
|
span = SPANS[i]; if (!span) continue;
|
||||||
bbox = span.bbox;
|
bbox = span.bbox; parent = this.parentNode(span);
|
||||||
if (bbox.exactW || bbox.width || bbox.w === 0 || bbox.isMultiline) {
|
if (bbox.exactW || bbox.width || bbox.w === 0 || bbox.isMultiline) {
|
||||||
if (!span.parentNode.bbox) {span.parentNode.bbox = bbox}
|
if (!parent.bbox) {parent.bbox = bbox}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (this.negativeBBoxes || !span.firstChild || (bbox.w >= 0 && !this.initialSkipBug) ||
|
if (this.negativeBBoxes || !span.firstChild || (bbox.w >= 0 && !this.initialSkipBug) ||
|
||||||
|
@ -787,11 +787,11 @@
|
||||||
// Read the widths and heights
|
// Read the widths and heights
|
||||||
//
|
//
|
||||||
for (i = 0, m = spans.length; i < m; i++) {
|
for (i = 0, m = spans.length; i < m; i++) {
|
||||||
span = spans[i][0]; bbox = span.bbox; var parent = span.parentNode;
|
span = spans[i][0]; bbox = span.bbox; parent = this.parentNode(span);
|
||||||
if ((bbox.w >= 0 && !this.initialSkipBug) || this.negativeBBoxes || !span.firstChild) {
|
if ((bbox.w >= 0 && !this.initialSkipBug) || this.negativeBBoxes || !span.firstChild) {
|
||||||
W = span.offsetWidth; parent.HH = span.parentNode.offsetHeight/this.em;
|
W = span.offsetWidth; parent.HH = parent.offsetHeight/this.em;
|
||||||
} else if (bbox.w < 0 && this.msieNegativeBBoxBug) {
|
} else if (bbox.w < 0 && this.msieNegativeBBoxBug) {
|
||||||
W = -span.offsetWidth, parent.HH = span.parentNode.offsetHeight/this.em;
|
W = -span.offsetWidth, parent.HH = parent.offsetHeight/this.em;
|
||||||
} else {
|
} else {
|
||||||
W = spans[i][2].offsetLeft - ((spans[i][1]||{}).offsetLeft||0);
|
W = spans[i][2].offsetLeft - ((spans[i][1]||{}).offsetLeft||0);
|
||||||
}
|
}
|
||||||
|
@ -972,6 +972,15 @@
|
||||||
return frame;
|
return frame;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
//
|
||||||
|
// Find parent span (skipping over <a> tags)
|
||||||
|
//
|
||||||
|
parentNode: function (span) {
|
||||||
|
var parent = span.parentNode;
|
||||||
|
if (parent.nodeName.toLowerCase() === "a") {parent = parent.parentNode}
|
||||||
|
return parent;
|
||||||
|
},
|
||||||
|
|
||||||
createStack: function (span,nobbox,w) {
|
createStack: function (span,nobbox,w) {
|
||||||
if (this.msiePaddingWidthBug) {this.createStrut(span,0)}
|
if (this.msiePaddingWidthBug) {this.createStrut(span,0)}
|
||||||
var relativeW = String(w).match(/%$/);
|
var relativeW = String(w).match(/%$/);
|
||||||
|
@ -1002,7 +1011,7 @@
|
||||||
},
|
},
|
||||||
placeBox: function (span,x,y,noclip) {
|
placeBox: function (span,x,y,noclip) {
|
||||||
span.isMathJax = true;
|
span.isMathJax = true;
|
||||||
var parent = span.parentNode, bbox = span.bbox, BBOX = parent.bbox;
|
var parent = HTMLCSS.parentNode(span), bbox = span.bbox, BBOX = parent.bbox;
|
||||||
if (this.msiePlaceBoxBug) {this.addText(span,this.NBSP)}
|
if (this.msiePlaceBoxBug) {this.addText(span,this.NBSP)}
|
||||||
if (this.imgSpaceBug) {this.addText(span,this.imgSpace)}
|
if (this.imgSpaceBug) {this.addText(span,this.imgSpace)}
|
||||||
// Place the box
|
// Place the box
|
||||||
|
|
Loading…
Reference in New Issue
Block a user