зеркало из https://github.com/mozilla/gecko-dev.git
Bug #429181 - Microformats - header/include coexistence not working
r=sayre
This commit is contained in:
Родитель
6b5cb5656c
Коммит
38240cfff5
|
@ -802,40 +802,44 @@ var Microformats = {
|
|||
*/
|
||||
preProcessMicroformat: function preProcessMicroformat(in_mfnode) {
|
||||
var mfnode;
|
||||
var includes = Microformats.getElementsByClassName(in_mfnode, "include");
|
||||
if ((includes.length > 0) || ((in_mfnode.nodeName.toLowerCase() == "td") && (in_mfnode.getAttribute("headers")))) {
|
||||
if ((in_mfnode.nodeName.toLowerCase() == "td") && (in_mfnode.getAttribute("headers"))) {
|
||||
mfnode = in_mfnode.cloneNode(true);
|
||||
mfnode.origNode = in_mfnode;
|
||||
if (includes.length > 0) {
|
||||
includes = Microformats.getElementsByClassName(mfnode, "include");
|
||||
var includeId;
|
||||
var include_length = includes.length;
|
||||
for (let i = include_length -1; i >= 0; i--) {
|
||||
if (includes[i].nodeName.toLowerCase() == "a") {
|
||||
includeId = includes[i].getAttribute("href").substr(1);
|
||||
}
|
||||
if (includes[i].nodeName.toLowerCase() == "object") {
|
||||
includeId = includes[i].getAttribute("data").substr(1);
|
||||
}
|
||||
if (in_mfnode.ownerDocument.getElementById(includeId)) {
|
||||
includes[i].parentNode.replaceChild(in_mfnode.ownerDocument.getElementById(includeId).cloneNode(true), includes[i]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var headers = in_mfnode.getAttribute("headers").split(" ");
|
||||
for (let i = 0; i < headers.length; i++) {
|
||||
var tempNode = in_mfnode.ownerDocument.createElement("span");
|
||||
var headerNode = in_mfnode.ownerDocument.getElementById(headers[i]);
|
||||
if (headerNode) {
|
||||
tempNode.innerHTML = headerNode.innerHTML;
|
||||
tempNode.className = headerNode.className;
|
||||
mfnode.appendChild(tempNode);
|
||||
}
|
||||
var headers = in_mfnode.getAttribute("headers").split(" ");
|
||||
for (let i = 0; i < headers.length; i++) {
|
||||
var tempNode = in_mfnode.ownerDocument.createElement("span");
|
||||
var headerNode = in_mfnode.ownerDocument.getElementById(headers[i]);
|
||||
if (headerNode) {
|
||||
tempNode.innerHTML = headerNode.innerHTML;
|
||||
tempNode.className = headerNode.className;
|
||||
mfnode.appendChild(tempNode);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mfnode = in_mfnode;
|
||||
}
|
||||
var includes = Microformats.getElementsByClassName(mfnode, "include");
|
||||
if (includes.length > 0) {
|
||||
/* If we didn't clone, clone now */
|
||||
if (!mfnode.origNode) {
|
||||
mfnode = in_mfnode.cloneNode(true);
|
||||
mfnode.origNode = in_mfnode;
|
||||
}
|
||||
includes = Microformats.getElementsByClassName(mfnode, "include");
|
||||
var includeId;
|
||||
var include_length = includes.length;
|
||||
for (let i = include_length -1; i >= 0; i--) {
|
||||
if (includes[i].nodeName.toLowerCase() == "a") {
|
||||
includeId = includes[i].getAttribute("href").substr(1);
|
||||
}
|
||||
if (includes[i].nodeName.toLowerCase() == "object") {
|
||||
includeId = includes[i].getAttribute("data").substr(1);
|
||||
}
|
||||
if (in_mfnode.ownerDocument.getElementById(includeId)) {
|
||||
includes[i].parentNode.replaceChild(in_mfnode.ownerDocument.getElementById(includeId).cloneNode(true), includes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return mfnode;
|
||||
},
|
||||
validate: function validate(mfnode, mfname) {
|
||||
|
|
|
@ -141,6 +141,22 @@ Doe</span>
|
|||
</span>
|
||||
</div>
|
||||
|
||||
<span id="austin" class="location">Austin - Sixth Street</span>
|
||||
<table summary="Timetable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th id="location-1"><a href="#austin" class="include"></a>New York</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th id="time-1"><abbr title="2008-01-01" class="dtstart">Jan 1, 2008</abbr></th>
|
||||
<td id="nested_header_include" class="vevent" headers="time-1 location-1"><div class="summary">New Years Party</div></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
@ -211,7 +227,12 @@ function test_Microformats() {
|
|||
|
||||
var dateCal = new hCalendar(document.getElementById("vcal_vcard"));
|
||||
is(dateCal.description, "Mozilla's Birthday", "vcard in vcal");
|
||||
|
||||
|
||||
var nestedCal = new hCalendar(document.getElementById("nested_header_include"));
|
||||
is(nestedCal.dtstart, "2008-01-01", "nested_header_include - dtstart");
|
||||
is(nestedCal.location, "Austin - Sixth Street", "nested_header_include - location");
|
||||
is(nestedCal.summary, "New Years Party", "nested_header_include - summary");
|
||||
|
||||
var valueCard = new hCard(document.getElementById("valuespace_1"));
|
||||
is(valueCard.fn, "John Doe", "valuespace_1");
|
||||
var valueCard = new hCard(document.getElementById("valuespace_2"));
|
||||
|
|
Загрузка…
Ссылка в новой задаче