Closed Bug 6121 Opened 25 years ago Closed 25 years ago

JS code to sort XML list worked in Preview 1 but fails silently in M5--why?

Categories

(Core :: DOM: Core & HTML, defect, P3)

x86
Windows NT
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: ekrock, Assigned: vidur)

References

()

Details

Attachments

(2 files)

Open the URL and click the Airline, Price, and Time buttons. In Developer Preview 1, the buttons resort the lists; in M5, they fail silently. Why? Pasted here are: 1) the XML file flights-sort.xml 2) the JS file flights.js It would be great if we can get this working, perhaps by figuring out something in the JS that needs to be updated? This is our main Gecko marketing demo. Thanks! ----------------- flights-sort.xml ------------------------------- <?xml version="1.0"?> <?xml-stylesheet href="common.css" type="text/css"?> <?xml-stylesheet href="list.css" type="text/css"?> <?xml-stylesheet href="classic.css" type="text/css"?> <!DOCTYPE BookSet> <SearchResult xmlns:html="http://www.w3.org/TR/REC-html40"> <Header> <Toggler> <html:form> <html:input type="button" id="toggle" value="Toggle Style" onclick="initiateToggle(); return false;"/> </html:form> </Toggler> <SearchTitle>Jump! Travel Best Fares</SearchTitle> <Toolbar> <html:form> <Label>Sort by:</Label> <html:input type="button" id="AIRLINE" onclick="sort(flights,this.id)" value="Airline"/> <html:input type="button" id="PRICE" onclick="sort(flights,this.id)" value="Price"/> <html:input type="button" id="DEPART" onclick="sort(flights,this.id)" value="Time"/> </html:form> </Toolbar> </Header> <FlightSet> <Flight> <Logo><html:img src="aa.gif" width="55" height="55" /></Logo> <Airline>American Airlines</Airline> <Number xml:link="simple" show="replace" href="http://dps1.travelocity.com:80/airgdetails.ctl?aln_code=AA&amp;dep_dt=1998 1223&amp;dep_arp_code=SFO&amp;arr_arp_code=BOS&amp;flt_num=196&amp;aln_name=Amer ican%20Airlines&amp;rqs_dow=Wednesday&amp;logo_name=ag_aalogo.gif&amp;SEQ=912556 613496799"> Flight 196 </Number> <Depart>Departs at 7:00</Depart> <Price>$385.00</Price> </Flight> <Flight> <Logo><html:img src="united.gif" width="55" height="55" /></Logo> <Airline>United Airlines</Airline> <Number xml:link="simple" show="replace" href="http://dps1.travelocity.com:80/airgdetails.ctl?aln_code=AA&amp;dep_dt=1998 1223&amp;dep_arp_code=SFO&amp;arr_arp_code=BOS&amp;flt_num=196&amp;aln_name=Amer ican%20Airlines&amp;rqs_dow=Wednesday&amp;logo_name=ag_aalogo.gif&amp;SEQ=912556 613496799"> Flight 174 </Number> <Depart>Departs at 8:45</Depart> <Price>$445.00</Price> </Flight> <Flight> <Logo><html:img src="united.gif" width="55" height="55" /></Logo> <Airline>United Airlines</Airline> <Number xml:link="simple" show="replace" href="http://dps1.travelocity.com:80/airgdetails.ctl?aln_code=AA&amp;dep_dt=1998 1223&amp;dep_arp_code=SFO&amp;arr_arp_code=BOS&amp;flt_num=196&amp;aln_name=Amer ican%20Airlines&amp;rqs_dow=Wednesday&amp;logo_name=ag_aalogo.gif&amp;SEQ=912556 613496799"> Flight 180 </Number> <Depart>Departs at 9:55</Depart> <Price>$445.00</Price> </Flight> <Flight> <Logo><html:img src="nw.gif" width="55" height="55" /></Logo> <Airline>Northwest Airlines</Airline> <Number xml:link="simple" show="replace" href="http://dps1.travelocity.com:80/airgdetails.ctl?aln_code=AA&amp;dep_dt=1998 1223&amp;dep_arp_code=SFO&amp;arr_arp_code=BOS&amp;flt_num=196&amp;aln_name=Amer ican%20Airlines&amp;rqs_dow=Wednesday&amp;logo_name=ag_aalogo.gif&amp;SEQ=912556 613496799"> Flight 350 </Number> <Depart>Departs at 5:00</Depart> <Price>$449.00</Price> </Flight> <Flight> <Logo><html:img src="dl.gif" width="55" height="55" /></Logo> <Airline>Delta Airlines</Airline> <Number xml:link="simple" show="replace" href="http://dps1.travelocity.com:80/airgdetails.ctl?aln_code=AA&amp;dep_dt=1998 1223&amp;dep_arp_code=SFO&amp;arr_arp_code=BOS&amp;flt_num=196&amp;aln_name=Amer ican%20Airlines&amp;rqs_dow=Wednesday&amp;logo_name=ag_aalogo.gif&amp;SEQ=912556 613496799"> Flight 2608 </Number> <Depart>Departs at 5:30</Depart> <Price>$521.00</Price> </Flight> </FlightSet> <html:script src="flights.js" /> </SearchResult> --------------------- flights. js --------------------------------- // An inefficient, but effective bubble sort function sort(collection, key) { var i, j; var count = collection.length; var parent, child; for (i = count-1; i >= 0; i--) { for (j = 1; j <= i; j++) { if (collection[j-1][key] > collection[j][key]) { // Move the item both in the local array and // in the tree child = collection[j]; parent = child.parentNode; collection[j] = collection[j-1]; collection[j-1] = child; parent.removeChild(child); parent.insertBefore(child, collection[j]); } } } } // Set user properties on the nodes in the collection // based on information found in its children. For example, // make a property "AIRLINE" based on the content of the // "Airline" element found in the childNode list of the node. // This makes later sorting more efficient function collectInfo(nodes, propNames) { var i, j, k; var ncount = nodes.length; var pcount = propNames.length; for (i = 0; i < ncount; i++) { var node = nodes[i]; var childNodes = node.childNodes; var ccount = childNodes.length; for (j = 0; j < ccount; j++) { var child = childNodes[j]; if (child.nodeType == Node.ELEMENT_NODE) { var tagName = child.tagName; for (k = 0; k < pcount; k++) { var prop = propNames[k]; if (prop == tagName.toUpperCase()) { node[prop] = child.firstChild.data; } } } } } } var enabled = true; function toggleStyleSheet() { if (enabled) { document.styleSheets[2].disabled = true; } else { document.styleSheets[2].disabled = false; } enabled = !enabled; } // XXX This is a workaround for a bug where // changing the disabled state of a stylesheet can't // be done in an event handler. For now, we do it // in a zero-delay timeout. function initiateToggle() { setTimeout(toggleStyleSheet, 0); } var sortableProps = new Array("AIRLINE", "PRICE", "DEPART"); var flights = new Array(); // We uppercase the tagName as a workaround for a bug // that loses the original case of the tag. // // 7 May 99 ekrock changed to lowercase with no effect var flightset = document.getElementsByTagName("flight"); // We need to create a "non-live" array to operate on. Since // we'll be moving things around in this array, we can't use // the read-only, live one returned by getElementsByTagName. for (var i=0; i < flightset.length; i++) { flights[i] = flightset[i]; } collectInfo(flights, sortableProps);
Attached file Books XML file (deleted) —
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Attached file Books js file (deleted) —
The code listed below actually had workarounds for bugs that currently don't exist. The biggest one had to do with our uppercasing of tagNames for XML elements in Preview 1. I've attached an udpated books demo (the demo on which the flights demo was based). Simple inspection will tell you what needs to be changed.
Confirmed fixed by ekrock in M5 AppRunner on WinNT. Confirmation URL for anyone who wants to doublecheck or check platform parity is http://blues/users/ekrock/publish/bugs/M4/xmlfixed/xml/flights.xml We had to update the demo to drop some old workaround code no longer needed. Thanks to Vidur!
Status: RESOLVED → VERIFIED
Verified on Win NT 1999-08-27-08, Mac 1999-08-19-11 and Linux 1999-08-16-09 builds.
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: