Bug #433884 - r=sayre - Microformats - Invalid geos should not appear in vcard at all

This commit is contained in:
Michael Kaply 2008-09-21 19:05:06 -05:00
parent a1701eca46
commit 9bf32f765f
2 changed files with 31 additions and 3 deletions

View File

@ -569,10 +569,18 @@ var Microformats = {
break;
case "microformat":
try {
result = new Microformats[prop.microformat].mfObject(node);
result = new Microformats[prop.microformat].mfObject(node, true);
} catch (ex) {
/* We can swallow this exception. If the creation of the */
/* mf object fails, then the node isn't a microformat */
/* There are two reasons we get here, one because the node is not */
/* a microformat and two because the node is a microformat and */
/* creation failed. If the node is not a microformat, we just fall */
/* through and use the default getter since there are some cases */
/* (location in hCalendar) where a property can be either a microformat */
/* or a string. If creation failed, we break and simply don't add the */
/* microformat property to the parent microformat */
if (ex != "Node is not a microformat (" + prop.microformat + ")") {
break;
}
}
if (result != undefined) {
if (prop.microformat_property) {

View File

@ -93,6 +93,19 @@
</div>
<span class="dtstart">1998-01-22</span>
</div>
<div id="geo_vcard" class="vcard">
<span class="fn">John Doe</span>
<span class="geo" id="ill_geo5">abc;def</span>
</div>
<div id="loc_vevent" class="vevent">
<span class="summary">Party</span>
<span class="location">The White House</span>
</div>
<div id="loc_vcard_vevent" class="vevent">
<span class="summary">Party</span>
<span class="location vcard"><span class="fn">The White House</span></span>
</div>
<div class="vcard" id="valuespace_1">
<span class="fn">
@ -228,6 +241,13 @@ function test_Microformats() {
var dateCal = new hCalendar(document.getElementById("vcal_vcard"));
is(dateCal.description, "Mozilla's Birthday", "vcard in vcal");
var hcard = new hCard(document.getElementById("geo_vcard"));
ok(!hcard.geo, "Check if invalid geo does not exist");
var hcal = new hCalendar(document.getElementById("loc_vevent"));
is(hcal.location, "The White House", "Check if non vcard location works");
var hcal = new hCalendar(document.getElementById("loc_vcard_vevent"));
is(hcal.location.fn, "The White House", "Check if vcard location works");
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");