MCPcopy
hub / github.com/layui/layui / domManip

Function domManip

src/modules/jquery.js:5947–6059  ·  view source on GitHub ↗
(collection, args, callback, ignored)

Source from the content-addressed store, hash-verified

5945 }
5946
5947 function domManip(collection, args, callback, ignored) {
5948 // Flatten any nested arrays
5949 args = flat(args);
5950
5951 var fragment,
5952 first,
5953 scripts,
5954 hasScripts,
5955 node,
5956 doc,
5957 i = 0,
5958 l = collection.length,
5959 iNoClone = l - 1,
5960 value = args[0],
5961 valueIsFunction = isFunction(value);
5962
5963 // We can't cloneNode fragments that contain checked, in WebKit
5964 if (
5965 valueIsFunction ||
5966 (l > 1 &&
5967 typeof value === 'string' &&
5968 !support.checkClone &&
5969 rchecked.test(value))
5970 ) {
5971 return collection.each(function (index) {
5972 var self = collection.eq(index);
5973 if (valueIsFunction) {
5974 args[0] = value.call(this, index, self.html());
5975 }
5976 domManip(self, args, callback, ignored);
5977 });
5978 }
5979
5980 if (l) {
5981 fragment = buildFragment(
5982 args,
5983 collection[0].ownerDocument,
5984 false,
5985 collection,
5986 ignored
5987 );
5988 first = fragment.firstChild;
5989
5990 if (fragment.childNodes.length === 1) {
5991 fragment = first;
5992 }
5993
5994 // Require either new content or an interest in ignored elements to invoke the callback
5995 if (first || ignored) {
5996 scripts = jQuery.map(getAll(fragment, 'script'), disableScript);
5997 hasScripts = scripts.length;
5998
5999 // Use the original fragment for the last item
6000 // instead of the first because it can end up
6001 // being emptied incorrectly in certain situations (trac-8070).
6002 for (; i < l; i++) {
6003 node = fragment;
6004

Callers 1

jquery.jsFile · 0.85

Calls 4

isFunctionFunction · 0.85
buildFragmentFunction · 0.85
getAllFunction · 0.85
DOMEvalFunction · 0.85

Tested by

no test coverage detected