mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
0ca9b00100
Note that the compiled .js file (generated by "make"/"make test") is still under version control so folks can work on the project even without a running "coffee" command in PATH. Also updated README to mention coffee-script and "make test".
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
|
|
module.exports = function(HTML5) {
|
|
var htmlparser;
|
|
htmlparser = new HTML5.Parser;
|
|
htmlparser.tree.elementInActiveFormattingElements = function(name) {
|
|
var els, i;
|
|
els = this.activeFormattingElements;
|
|
i = els.length - 1;
|
|
while (i >= 0) {
|
|
if (els[i].type === HTML5.Marker.type) break;
|
|
if (els[i].tagName.toLowerCase() === name) return els[i];
|
|
i--;
|
|
}
|
|
return false;
|
|
};
|
|
htmlparser.tree.reconstructActiveFormattingElements = function() {
|
|
var clone, element, entry, i;
|
|
if (this.activeFormattingElements.length === 0) return;
|
|
i = this.activeFormattingElements.length - 1;
|
|
entry = this.activeFormattingElements[i];
|
|
if (entry.type === HTML5.Marker.type || this.open_elements.indexOf(entry) !== -1) {
|
|
return;
|
|
}
|
|
while (entry.type !== HTML5.Marker.type && this.open_elements.indexOf(entry) === -1) {
|
|
i -= 1;
|
|
entry = this.activeFormattingElements[i];
|
|
if (!entry) break;
|
|
}
|
|
while (true) {
|
|
i += 1;
|
|
clone = this.activeFormattingElements[i].cloneNode();
|
|
element = this.insert_element(clone.tagName, clone.attributes);
|
|
this.activeFormattingElements[i] = element;
|
|
if (element === this.activeFormattingElements.last()) break;
|
|
}
|
|
};
|
|
return htmlparser;
|
|
};
|