1 /**
  2  * @fileOverview overrides methods in NodeList.prototype
  3  * @author yiminghe@gmail.com
  4  */
  5 KISSY.add("node/override", function (S, DOM, Event, NodeList) {
  6 
  7     var NLP = NodeList.prototype;
  8 
  9     /**
 10      * append(node ,parent) : 参数顺序反过来了
 11      * appendTo(parent,node) : 才是正常
 12      *
 13      */
 14     S.each(['append', 'prepend', 'before', 'after'], function (insertType) {
 15         NLP[insertType] = function (html) {
 16             var newNode = html, self = this;
 17             // 创建
 18             if (S.isString(newNode)) {
 19                 newNode = DOM.create(newNode);
 20             }
 21             if (newNode) {
 22                 DOM[insertType](newNode, self);
 23             }
 24             return self;
 25         };
 26     });
 27 
 28     S.each(["wrap", "wrapAll", "replaceWith", "wrapInner"], function (fixType) {
 29         var orig = NLP[fixType];
 30         NLP[fixType] = function (others) {
 31             var self = this;
 32             if (S.isString(others)) {
 33                 others = NodeList.all(others, self[0].ownerDocument);
 34             }
 35             return orig.call(self, others);
 36         };
 37     })
 38 
 39 }, {
 40     requires:["dom", "event", "./base", "./attach"]
 41 });
 42 
 43 /**
 44  * 2011-04-05 yiminghe@gmail.com
 45  * - 增加 wrap/wrapAll/replaceWith/wrapInner/unwrap/contents
 46  *
 47  * 2011-05-24
 48  * - 承玉:
 49  * - 重写 NodeList 的某些方法
 50  * - 添加 one ,all ,从当前 NodeList 往下开始选择节点
 51  * - 处理 append ,prepend 和 DOM 的参数实际上是反过来的
 52  * - append/prepend 参数是节点时,如果当前 NodeList 数量 > 1 需要经过 clone,因为同一节点不可能被添加到多个节点中去(NodeList)
 53  */