Changes between Version 1 and Version 2 of Ticket #9406


Ignore:
Timestamp:
Jun 14, 2009, 7:45:07 PM (10 years ago)
Author:
Eugene Lazutkin
Comment:

This change effectively aliases adopt to addContent:

dojo.NodeList.adopt = dojo.NodeList.addContent;

While it is laudable, because it reduces the codebase, I am not so sure about James' point number 2: copying DOM nodes instead of moving them. Without this functionality there is no need for adopt(). We can preserve it by moving the functionality in another direction: NodeList.place():

adopt: function(/*String||Array||DomNode*/ queryOrListOrNode, /*String?*/ position){
  d.query(queryOrNode).place(this[0], position);
  return this; // NodeList
}

Which reminds me of another deficiency in place(): it behaves strangely with different position arguments. Intuitively I expect that all elements will be inserted as one fragment in a position of my choosing. In practice:

first
Inserts all elements in the beginning of the child list reversing their order.
only
Inserts the last element of the list as the only child.
last
Behaves as I expect it.
before
Behaves as I expect it.
replace
Throws if the list contains more than 1 element.
after
Inserts all elements after the current element reversing their order.

I cannot believe that this is the intentional behavior. The test file is included.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #9406

    • Property Type changed from defect to enhancement
  • Ticket #9406 – Description

    v1 v2  
    22
    33{{{
     4#!js
    45adopt: function(/*String||Array||DomNode*/ queryOrListOrNode, /*String?*/ position){
    56  return this.addContent(d.query(queryOrListOrNode), position);