зеркало из https://github.com/mozilla/gecko-dev.git
416197 - r=sayrer, a=schrep - value excerpting only applies to child nodes
This commit is contained in:
Родитель
dd6b5cd3cf
Коммит
4449a9734d
|
@ -300,40 +300,45 @@ var Microformats = {
|
|||
return propnode.value;
|
||||
} else {
|
||||
var values = Microformats.getElementsByClassName(propnode, "value");
|
||||
/* Verify that values are children of the propnode */
|
||||
for (let i = values.length-1; i >= 0; i--) {
|
||||
if (values[i].parentNode != propnode) {
|
||||
values.splice(i,1);
|
||||
}
|
||||
}
|
||||
if (values.length > 0) {
|
||||
var value = "";
|
||||
for (let j=0;j<values.length;j++) {
|
||||
value += Microformats.parser.defaultGetter(values[j], propnode, datatype);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
var s;
|
||||
if (datatype == "HTML") {
|
||||
s = propnode.innerHTML;
|
||||
} else {
|
||||
var s;
|
||||
if (datatype == "HTML") {
|
||||
s = propnode.innerHTML;
|
||||
if (propnode.innerText) {
|
||||
s = propnode.innerText;
|
||||
} else {
|
||||
if (propnode.innerText) {
|
||||
s = propnode.innerText;
|
||||
} else {
|
||||
s = propnode.textContent;
|
||||
}
|
||||
}
|
||||
/* If we are processing a value node, don't remove whitespace */
|
||||
if (!Microformats.matchClass(propnode, "value")) {
|
||||
/* Remove new lines, carriage returns and tabs */
|
||||
s = s.replace(/[\n\r\t]/gi, ' ');
|
||||
/* Replace any double spaces with single spaces */
|
||||
s = s.replace(/\s{2,}/gi, ' ');
|
||||
/* Remove any double spaces that are left */
|
||||
s = s.replace(/\s{2,}/gi, '');
|
||||
/* Remove any spaces at the beginning */
|
||||
s = s.replace(/^\s+/, '');
|
||||
/* Remove any spaces at the end */
|
||||
s = s.replace(/\s+$/, '');
|
||||
}
|
||||
if (s.length > 0) {
|
||||
return s;
|
||||
s = propnode.textContent;
|
||||
}
|
||||
}
|
||||
/* If we are processing a value node, don't remove whitespace */
|
||||
if (!Microformats.matchClass(propnode, "value")) {
|
||||
/* Remove new lines, carriage returns and tabs */
|
||||
s = s.replace(/[\n\r\t]/gi, ' ');
|
||||
/* Replace any double spaces with single spaces */
|
||||
s = s.replace(/\s{2,}/gi, ' ');
|
||||
/* Remove any double spaces that are left */
|
||||
s = s.replace(/\s{2,}/gi, '');
|
||||
/* Remove any spaces at the beginning */
|
||||
s = s.replace(/^\s+/, '');
|
||||
/* Remove any spaces at the end */
|
||||
s = s.replace(/\s+$/, '');
|
||||
}
|
||||
if (s.length > 0) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
|
|
@ -59,7 +59,13 @@
|
|||
</div>
|
||||
</a>
|
||||
|
||||
|
||||
<div class="vcard" id="value_test">
|
||||
<span class="fn">
|
||||
<span class="value">John</span>
|
||||
<span><span class="value">Middle</span></span>
|
||||
<span class="value">Doe</span>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
|
@ -107,6 +113,10 @@ function test_Microformats() {
|
|||
|
||||
var inner_parent = Microformats.getParent(document.getElementById("inner_vevent5"));
|
||||
is(inner_parent.id, "outer_tag5", "GetParent gets correct ancestor 5");
|
||||
|
||||
var valueCard = new hCard(document.getElementById("value_test"));
|
||||
|
||||
is(valueCard.fn, "JohnDoe", "value_test");
|
||||
}
|
||||
|
||||
function test_hCard() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче