Closed
Bug 415974
Opened 18 years ago
Closed 18 years ago
Microformats.getParent returns wrong node when two or more ancestors are of the same type of microformat
Categories
(Toolkit Graveyard :: Microformats, defect)
Toolkit Graveyard
Microformats
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: mkaply, Assigned: mkaply)
References
Details
Attachments
(1 file, 1 obsolete file)
8.39 KB,
patch
|
sayrer
:
review+
mtschrep
:
approval1.9+
|
Details | Diff | Splinter Review |
If you have a scenario like this:
<div class="vcard" id="outer_vcard">
<div class="vcard" id="middle_vcard">
<div class="vcard" id="inner_vcard">
<span class="fn">Inner User</span>
</div>
<span class="fn">Middle User</span>
</div>
<span class="fn">Outer User</span>
</div>
And you ask the "inner_vcard" what its parent is, it will tell you "outer_vcard" instead of "middle_vcard"
Fix is to be more explicit in what node I get from the XPath
testcase is attached as well.
Note testcase has some rework of the original microformats testcase to make it easier to add new tests.
Attachment #301721 -
Flags: review?(sayrer)
Assignee | ||
Comment 1•18 years ago
|
||
This isn't right either. There still seem to be cases where I get a different ancestor.
Jonas:
What is the correct xpath for "get my immediate ancestor that has a certain classname?
Thanks!
Assignee | ||
Comment 2•18 years ago
|
||
Comment on attachment 301721 [details] [diff] [review]
Fix for problem - get the [1] node from xpath
Actually I'm doing this wrong.
Because I'm enumerating through the list first, I find the first parent that corresponds to the earliest microformat.
What I need to do is find the first parent that has any of my microformat class names. Solution coming.
Attachment #301721 -
Flags: review?(sayrer)
Attachment #301721 -
Attachment is patch: true
Attachment #301721 -
Attachment mime type: application/octet-stream → text/plain
./ancestor::*[class='foo'][1]
Should return the innermost ancestor with a given class. So in the example above
./ancestor::*[class='vcard']
should yield the 'inner_vcard' node if the context node is the span.
If you want "the innermost ancestor but only if it has a certain class" the expression would be
./ancestor::*[1][class='vcard']
Assignee | ||
Comment 4•18 years ago
|
||
This is a rewrite of getparent to construct one xpath to do what we need.
It also has full unit test with all permutations.
Attachment #301721 -
Attachment is obsolete: true
Attachment #301797 -
Flags: review?(sayrer)
Updated•18 years ago
|
Attachment #301797 -
Flags: review?(sayrer) → review+
Assignee | ||
Updated•18 years ago
|
Attachment #301797 -
Flags: approval1.9?
Updated•18 years ago
|
Attachment #301797 -
Flags: approval1.9? → approval1.9+
Assignee | ||
Comment 5•18 years ago
|
||
Fixed
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Updated•6 years ago
|
Product: Toolkit → Toolkit Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•