430466, r=sayre, a=dsicore, Need to check against undefined to determine existence so we handle 0 lat/long

This commit is contained in:
mkaply@us.ibm.com 2008-04-23 13:10:12 -07:00
parent 22e0e5404f
commit 60de8bf009
2 changed files with 31 additions and 7 deletions

View File

@ -552,7 +552,7 @@ var Microformats = {
/* We can swallow this exception. If the creation of the */
/* mf object fails, then the node isn't a microformat */
}
if (result) {
if (result != undefined) {
if (prop.microformat_property) {
result = result[prop.microformat_property];
}
@ -564,12 +564,12 @@ var Microformats = {
}
/* This handles the case where one property implies another property */
/* For instance, org by itself is actually org.organization-name */
if ((prop.implied) && (result)) {
if (prop.implied && (result != undefined)) {
var temp = result;
result = {};
result[prop.implied] = temp;
}
if (result && prop.values) {
if (prop.values && (result != undefined)) {
var validType = false;
for (let value in prop.values) {
if (result.toLowerCase() == prop.values[value]) {
@ -643,7 +643,7 @@ var Microformats = {
subresult = Microformats.parser.getPropertyInternal(subpropnodes[i], propnode,
subpropobj,
subpropname, mfnode);
if (subresult) {
if (subresult != undefined) {
resultArray.push(subresult);
/* If we're not a plural property, don't bother getting more */
if (!subpropobj.plural) {
@ -655,7 +655,7 @@ var Microformats = {
subresult = Microformats.parser.getPropertyInternal(propnode, null,
subpropobj,
subpropname, mfnode);
if (subresult) {
if (subresult != undefined) {
resultArray.push(subresult);
}
}
@ -761,7 +761,7 @@ var Microformats = {
mfnode,
propobj,
propname);
if (subresult) {
if (subresult != undefined) {
resultArray.push(subresult);
/* If we're not a plural property, don't bother getting more */
if (!propobj.plural) {

View File

@ -48,7 +48,13 @@
<ABBR title="20080311" class="dtend">Tuesday, March 11, 2008</ABBR>
<abbr class="geo" id="02-geo-vevent-02" title="30.2622;-97.7399">Convention Center</abbr>
</span>
<h3>Legal geos</h3>
<ul>
<li><span class="geo" id="legal_geo1"><span class="latitude">0</span>,<span class="longitude">0</span></span></li>
<li><span class="geo" id="legal_geo2"><span class="latitude">0.0</span>,<span class="longitude">0.0</span></span></li>
<li><span class="geo" id="legal_geo3"><span class="latitude">0.</span>,<span class="longitude">0.</span></span></li>
</ul>
<h3>Illegal geos</h3>
<ul>
@ -123,6 +129,24 @@ function test_geo() {
is(Geo.toString(), "Convention Center", "02-geo-vevent-02");
Geo = new geo(document.getElementById("legal_geo1"));
is(Geo.latitude, 0, "legal_geo1 - lat");
is(Geo.longitude, 0, "legal_geo1 - long");
Geo = new geo(document.getElementById("legal_geo2"));
is(Geo.latitude, 0, "legal_geo2 - lat");
is(Geo.longitude, 0, "legal_geo2 - long");
Geo = new geo(document.getElementById("legal_geo3"));
is(Geo.latitude, 0, "legal_geo3 - lat");
is(Geo.longitude, 0, "legal_geo3 - long");
try {
Geo = new geo(document.getElementById("ill_geo1"), true);
ok(0, "ill_geo1 - should have been caught as invalid geo");