Skip to content
Permalink
Browse files

Move all helpers to the end of the module

  • Loading branch information
markelog committed Dec 23, 2012
1 parent a10dd52 commit 1043fa897156c077b96de8109c7869bf5b8381ab
Showing with 111 additions and 111 deletions.
  1. +111 −111 src/manipulation.js
@@ -342,97 +342,6 @@ jQuery.fn.extend({
}
});

function findOrAppend( elem, tag ) {
return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) );
}

// Replace/restore the type attribute of script elements for safe DOM manipulation
function disableScript( elem ) {
var attr = elem.getAttributeNode("type");
elem.type = ( attr && attr.specified ) + "/" + elem.type;
return elem;
}
function restoreScript( elem ) {
var match = rscriptTypeMasked.exec( elem.type );
if ( match ) {
elem.type = match[ 1 ];
} else {
elem.removeAttribute("type");
}
return elem;
}

// Mark scripts as having already been evaluated
function setGlobalEval( elems, refElements ) {
var elem,
i = 0;
for ( ; (elem = elems[ i ]) != null; i++ ) {
jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[ i ], "globalEval" ) );
}
}

function cloneCopyEvent( src, dest ) {

if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
return;
}

var type, i, l,
oldData = jQuery._data( src ),
curData = jQuery._data( dest, oldData ),
events = oldData.events;

if ( events ) {
delete curData.handle;
curData.events = {};

for ( type in events ) {
for ( i = 0, l = events[ type ].length; i < l; i++ ) {
jQuery.event.add( dest, type, events[ type ][ i ] );
}
}
}

// make the cloned public data object a copy from the original
if ( curData.data ) {
curData.data = jQuery.extend( {}, curData.data );
}
}

function fixCloneNodeIssues( src, dest ) {
var nodeName;

// We do not need to do anything for non-Elements
if ( dest.nodeType !== 1 ) {
return;
}

nodeName = dest.nodeName.toLowerCase();

if ( nodeName === "object" ) {
if ( dest.parentNode ) {
dest.outerHTML = src.outerHTML;
}

// This path appears unavoidable for IE9. When cloning an object
// element in IE9, the outerHTML strategy above is not sufficient.
// If the src has innerHTML and the destination does not,
// copy the src.innerHTML into the dest.innerHTML. #10324
if ( src.innerHTML && !jQuery.trim( dest.innerHTML ) ) {
dest.innerHTML = src.innerHTML;
}

// IE9-10 fails to persist the checked state of a cloned checkbox or radio button.
} else if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) {
dest.checked = src.checked;

// IE9-10 fails to return the selected option to the default selected
// state when cloning options
} else if ( nodeName === "input" || nodeName === "textarea" ) {
dest.defaultValue = src.defaultValue;
}
}

jQuery.each({
appendTo: "append",
prependTo: "prepend",
@@ -458,26 +367,6 @@ jQuery.each({
};
});

function getAll( context, tag ) {
var elems, elem,
i = 0,
ret = typeof context.getElementsByTagName !== "undefined" ? context.getElementsByTagName( tag || "*" ) :
typeof context.querySelectorAll !== "undefined" ? context.querySelectorAll( tag || "*" ) :
undefined;

if ( !ret ) {
for ( ret = [], elems = context.childNodes || context; (elem = elems[ i ]) != null; i++ ) {
core_push.apply( ret, !tag || jQuery.nodeName( elem, tag ) ?
getAll( elem, tag ) :
elems );
}
}

return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
jQuery.merge( [ context ], ret ) :
ret;
}

jQuery.extend({
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
var destElements, srcElements, node, i,
@@ -661,3 +550,114 @@ jQuery.extend({
}
}
});

function findOrAppend( elem, tag ) {
return elem.getElementsByTagName( tag )[ 0 ] || elem.appendChild( elem.ownerDocument.createElement( tag ) );
}

// Replace/restore the type attribute of script elements for safe DOM manipulation
function disableScript( elem ) {
var attr = elem.getAttributeNode("type");
elem.type = ( attr && attr.specified ) + "/" + elem.type;
return elem;
}
function restoreScript( elem ) {
var match = rscriptTypeMasked.exec( elem.type );
if ( match ) {
elem.type = match[ 1 ];
} else {
elem.removeAttribute("type");
}
return elem;
}

// Mark scripts as having already been evaluated
function setGlobalEval( elems, refElements ) {
var elem,
i = 0;
for ( ; (elem = elems[ i ]) != null; i++ ) {
jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[ i ], "globalEval" ) );
}
}

function cloneCopyEvent( src, dest ) {

if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
return;
}

var type, i, l,
oldData = jQuery._data( src ),
curData = jQuery._data( dest, oldData ),
events = oldData.events;

if ( events ) {
delete curData.handle;
curData.events = {};

for ( type in events ) {
for ( i = 0, l = events[ type ].length; i < l; i++ ) {
jQuery.event.add( dest, type, events[ type ][ i ] );
}
}
}

// make the cloned public data object a copy from the original
if ( curData.data ) {
curData.data = jQuery.extend( {}, curData.data );
}
}

function fixCloneNodeIssues( src, dest ) {
var nodeName;

// We do not need to do anything for non-Elements
if ( dest.nodeType !== 1 ) {
return;
}

nodeName = dest.nodeName.toLowerCase();

if ( nodeName === "object" ) {
if ( dest.parentNode ) {
dest.outerHTML = src.outerHTML;
}

// This path appears unavoidable for IE9. When cloning an object
// element in IE9, the outerHTML strategy above is not sufficient.
// If the src has innerHTML and the destination does not,
// copy the src.innerHTML into the dest.innerHTML. #10324
if ( src.innerHTML && !jQuery.trim( dest.innerHTML ) ) {
dest.innerHTML = src.innerHTML;
}

// IE9-10 fails to persist the checked state of a cloned checkbox or radio button.
} else if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) {
dest.checked = src.checked;

// IE9-10 fails to return the selected option to the default selected
// state when cloning options
} else if ( nodeName === "input" || nodeName === "textarea" ) {
dest.defaultValue = src.defaultValue;
}
}

function getAll( context, tag ) {
var elems, elem,
i = 0,
ret = typeof context.getElementsByTagName !== "undefined" ? context.getElementsByTagName( tag || "*" ) :
typeof context.querySelectorAll !== "undefined" ? context.querySelectorAll( tag || "*" ) :
undefined;

if ( !ret ) {
for ( ret = [], elems = context.childNodes || context; (elem = elems[ i ]) != null; i++ ) {
core_push.apply( ret, !tag || jQuery.nodeName( elem, tag ) ?
getAll( elem, tag ) :
elems );
}
}

return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
jQuery.merge( [ context ], ret ) :
ret;
}

0 comments on commit 1043fa8

Please sign in to comment.
You can’t perform that action at this time.