prototype: Add Element#childElements as an alias for Element#immediateDescendants.
This commit is contained in:
parent
5784d78f6e
commit
47bfeb5083
@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Add Element#childElements as an alias for Element#immediateDescendants. [Tobie Langel]
|
||||
|
||||
* Optimize DOM navigation methods (Element#up, Element#down, Element#previous, Element#next) for no-argument calls. Closes #7848. [haraldmartin, sam]
|
||||
|
||||
* Add Element#firstDescendant to retrieve the first non-text child node of an element. [sam]
|
||||
|
@ -426,7 +426,10 @@ Element.Methods = {
|
||||
}
|
||||
};
|
||||
|
||||
Object.extend(Element.Methods, {childOf: Element.Methods.descendantOf});
|
||||
Object.extend(Element.Methods, {
|
||||
childOf: Element.Methods.descendantOf,
|
||||
childElements: Element.Methods.immediateDescendants
|
||||
});
|
||||
|
||||
if (Prototype.Browser.Opera) {
|
||||
Element.Methods._getStyle = Element.Methods.getStyle;
|
||||
|
@ -484,16 +484,20 @@
|
||||
assertNull($('navigation_test_next_sibling').firstDescendant());
|
||||
}},
|
||||
|
||||
testElementImmediateDescendants: function() {with(this) {
|
||||
assertElementsMatch($('navigation_test').immediateDescendants(),
|
||||
testElementChildElements: function() {with(this) {
|
||||
assertElementsMatch($('navigation_test').childElements(),
|
||||
'li.first', 'li', 'li#navigation_test_c', 'li.last');
|
||||
assertNotEqual(0, $('navigation_test_next_sibling').childNodes.length);
|
||||
assertEnumEqual([], $('navigation_test_next_sibling').immediateDescendants());
|
||||
assertEnumEqual([], $('navigation_test_next_sibling').childElements());
|
||||
|
||||
var dummy = $(document.createElement('DIV'));
|
||||
dummy.innerHTML = '<div></div>'.times(3);
|
||||
assert(typeof dummy.immediateDescendants()[0].setStyle == 'function');
|
||||
assert(typeof dummy.childElements()[0].setStyle == 'function');
|
||||
}},
|
||||
|
||||
testElementImmediateDescendants: function() {with(this) {
|
||||
assertIdentical(Element.Methods.childElements, Element.Methods.immediateDescendants);
|
||||
}},
|
||||
|
||||
testElementPreviousSiblings: function() {with(this) {
|
||||
assertElementsMatch($('navigation_test').previousSiblings(),
|
||||
|
Loading…
Reference in New Issue
Block a user