Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
ec7fdf37
Commit
ec7fdf37
authored
Jul 19, 2009
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweaked formatting of src/manipulation.js.
parent
48e9a399
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
28 deletions
+40
-28
manipulation.js
src/manipulation.js
+40
-28
No files found.
src/manipulation.js
View file @
ec7fdf37
jQuery
.
fn
.
extend
({
jQuery
.
fn
.
extend
({
text
:
function
(
text
)
{
text
:
function
(
text
)
{
if
(
typeof
text
!==
"object"
&&
text
!=
null
)
if
(
typeof
text
!==
"object"
&&
text
!=
=
undefined
)
return
this
.
empty
().
append
(
(
this
[
0
]
&&
this
[
0
].
ownerDocument
||
document
).
createTextNode
(
text
)
);
return
this
.
empty
().
append
(
(
this
[
0
]
&&
this
[
0
].
ownerDocument
||
document
).
createTextNode
(
text
)
);
var
ret
=
""
;
var
ret
=
""
;
jQuery
.
each
(
text
||
this
,
function
(){
jQuery
.
each
(
text
||
this
,
function
(){
jQuery
.
each
(
this
.
childNodes
,
function
(){
jQuery
.
each
(
this
.
childNodes
,
function
(){
if
(
this
.
nodeType
!=
8
)
if
(
this
.
nodeType
!=
=
8
)
{
ret
+=
this
.
nodeType
!=
1
?
ret
+=
this
.
nodeType
!=
=
1
?
this
.
nodeValue
:
this
.
nodeValue
:
jQuery
.
fn
.
text
(
[
this
]
);
jQuery
.
fn
.
text
(
[
this
]
);
}
});
});
});
});
...
@@ -18,22 +19,26 @@ jQuery.fn.extend({
...
@@ -18,22 +19,26 @@ jQuery.fn.extend({
},
},
wrapAll
:
function
(
html
)
{
wrapAll
:
function
(
html
)
{
if
(
jQuery
.
isFunction
(
html
))
{
if
(
jQuery
.
isFunction
(
html
)
)
{
return
this
.
each
(
function
()
{
jQuery
(
this
).
wrapAll
(
html
.
call
(
this
));
});
return
this
.
each
(
function
()
{
jQuery
(
this
).
wrapAll
(
html
.
apply
(
this
,
arguments
)
);
});
}
}
if
(
this
[
0
]
)
{
if
(
this
[
0
]
)
{
// The elements to wrap the target around
// The elements to wrap the target around
var
wrap
=
jQuery
(
html
,
this
[
0
].
ownerDocument
).
eq
(
0
).
clone
();
var
wrap
=
jQuery
(
html
,
this
[
0
].
ownerDocument
).
eq
(
0
).
clone
();
if
(
this
[
0
].
parentNode
)
if
(
this
[
0
].
parentNode
)
{
wrap
.
insertBefore
(
this
[
0
]
);
wrap
.
insertBefore
(
this
[
0
]
);
}
wrap
.
map
(
function
(){
wrap
.
map
(
function
(){
var
elem
=
this
;
var
elem
=
this
;
while
(
elem
.
firstChild
&&
elem
.
firstChild
.
nodeType
===
1
)
while
(
elem
.
firstChild
&&
elem
.
firstChild
.
nodeType
===
1
)
{
elem
=
elem
.
firstChild
;
elem
=
elem
.
firstChild
;
}
return
elem
;
return
elem
;
}).
append
(
this
);
}).
append
(
this
);
...
@@ -56,15 +61,17 @@ jQuery.fn.extend({
...
@@ -56,15 +61,17 @@ jQuery.fn.extend({
append
:
function
()
{
append
:
function
()
{
return
this
.
domManip
(
arguments
,
true
,
function
(
elem
){
return
this
.
domManip
(
arguments
,
true
,
function
(
elem
){
if
(
this
.
nodeType
==
1
)
if
(
this
.
nodeType
===
1
)
{
this
.
appendChild
(
elem
);
this
.
appendChild
(
elem
);
}
});
});
},
},
prepend
:
function
()
{
prepend
:
function
()
{
return
this
.
domManip
(
arguments
,
true
,
function
(
elem
){
return
this
.
domManip
(
arguments
,
true
,
function
(
elem
){
if
(
this
.
nodeType
==
1
)
if
(
this
.
nodeType
===
1
)
{
this
.
insertBefore
(
elem
,
this
.
firstChild
);
this
.
insertBefore
(
elem
,
this
.
firstChild
);
}
});
});
},
},
...
@@ -109,8 +116,7 @@ jQuery.fn.extend({
...
@@ -109,8 +116,7 @@ jQuery.fn.extend({
var
orig
=
this
.
find
(
"*"
).
andSelf
(),
i
=
0
;
var
orig
=
this
.
find
(
"*"
).
andSelf
(),
i
=
0
;
ret
.
find
(
"*"
).
andSelf
().
each
(
function
(){
ret
.
find
(
"*"
).
andSelf
().
each
(
function
(){
if
(
this
.
nodeName
!==
orig
[
i
].
nodeName
)
if
(
this
.
nodeName
!==
orig
[
i
].
nodeName
)
{
return
;
}
return
;
var
events
=
jQuery
.
data
(
orig
[
i
],
"events"
);
var
events
=
jQuery
.
data
(
orig
[
i
],
"events"
);
...
@@ -141,8 +147,8 @@ jQuery.fn.extend({
...
@@ -141,8 +147,8 @@ jQuery.fn.extend({
},
},
domManip
:
function
(
args
,
table
,
callback
)
{
domManip
:
function
(
args
,
table
,
callback
)
{
var
fragment
,
scripts
,
cacheable
,
cached
,
cacheresults
,
first
;
var
fragment
,
scripts
,
cacheable
,
cached
,
cacheresults
,
first
,
var
value
=
args
[
0
];
value
=
args
[
0
];
if
(
jQuery
.
isFunction
(
value
)
)
{
if
(
jQuery
.
isFunction
(
value
)
)
{
return
this
.
each
(
function
()
{
return
this
.
each
(
function
()
{
...
@@ -262,8 +268,9 @@ jQuery.extend({
...
@@ -262,8 +268,9 @@ jQuery.extend({
context
=
context
||
document
;
context
=
context
||
document
;
// !context.createElement fails in IE with an error but returns typeof 'object'
// !context.createElement fails in IE with an error but returns typeof 'object'
if
(
typeof
context
.
createElement
===
"undefined"
)
if
(
typeof
context
.
createElement
===
"undefined"
)
{
context
=
context
.
ownerDocument
||
context
[
0
]
&&
context
[
0
].
ownerDocument
||
document
;
context
=
context
.
ownerDocument
||
context
[
0
]
&&
context
[
0
].
ownerDocument
||
document
;
}
// If a single string is passed in and it's a single tag
// If a single string is passed in and it's a single tag
// just do a createElement and skip the rest
// just do a createElement and skip the rest
...
@@ -276,11 +283,11 @@ jQuery.extend({
...
@@ -276,11 +283,11 @@ jQuery.extend({
var
ret
=
[],
scripts
=
[],
div
=
context
.
createElement
(
"div"
);
var
ret
=
[],
scripts
=
[],
div
=
context
.
createElement
(
"div"
);
jQuery
.
each
(
elems
,
function
(
i
,
elem
){
jQuery
.
each
(
elems
,
function
(
i
,
elem
){
if
(
typeof
elem
===
"number"
)
if
(
typeof
elem
===
"number"
)
{
elem
+=
''
;
elem
+=
''
;
}
if
(
!
elem
)
if
(
!
elem
)
{
return
;
}
return
;
// Convert html string into DOM nodes
// Convert html string into DOM nodes
if
(
typeof
elem
===
"string"
)
{
if
(
typeof
elem
===
"string"
)
{
...
@@ -325,8 +332,9 @@ jQuery.extend({
...
@@ -325,8 +332,9 @@ jQuery.extend({
div
.
innerHTML
=
wrap
[
1
]
+
elem
+
wrap
[
2
];
div
.
innerHTML
=
wrap
[
1
]
+
elem
+
wrap
[
2
];
// Move to the right depth
// Move to the right depth
while
(
wrap
[
0
]
--
)
while
(
wrap
[
0
]
--
)
{
div
=
div
.
lastChild
;
div
=
div
.
lastChild
;
}
// Remove IE's autoinserted <tbody> from table fragments
// Remove IE's autoinserted <tbody> from table fragments
if
(
!
jQuery
.
support
.
tbody
)
{
if
(
!
jQuery
.
support
.
tbody
)
{
...
@@ -341,23 +349,27 @@ jQuery.extend({
...
@@ -341,23 +349,27 @@ jQuery.extend({
div
.
childNodes
:
div
.
childNodes
:
[];
[];
for
(
var
j
=
tbody
.
length
-
1
;
j
>=
0
;
--
j
)
for
(
var
j
=
tbody
.
length
-
1
;
j
>=
0
;
--
j
)
{
if
(
jQuery
.
nodeName
(
tbody
[
j
],
"tbody"
)
&&
!
tbody
[
j
].
childNodes
.
length
)
if
(
jQuery
.
nodeName
(
tbody
[
j
],
"tbody"
)
&&
!
tbody
[
j
].
childNodes
.
length
)
{
tbody
[
j
].
parentNode
.
removeChild
(
tbody
[
j
]
);
tbody
[
j
].
parentNode
.
removeChild
(
tbody
[
j
]
);
}
}
}
}
// IE completely kills leading whitespace when innerHTML is used
// IE completely kills leading whitespace when innerHTML is used
if
(
!
jQuery
.
support
.
leadingWhitespace
&&
/^
\s
/
.
test
(
elem
)
)
if
(
!
jQuery
.
support
.
leadingWhitespace
&&
/^
\s
/
.
test
(
elem
)
)
{
div
.
insertBefore
(
context
.
createTextNode
(
/^
\s
*/
.
exec
(
elem
)[
0
]
),
div
.
firstChild
);
div
.
insertBefore
(
context
.
createTextNode
(
/^
\s
*/
.
exec
(
elem
)[
0
]
),
div
.
firstChild
);
}
elem
=
jQuery
.
makeArray
(
div
.
childNodes
);
elem
=
jQuery
.
makeArray
(
div
.
childNodes
);
}
}
if
(
elem
.
nodeType
)
if
(
elem
.
nodeType
)
{
ret
.
push
(
elem
);
ret
.
push
(
elem
);
else
}
else
{
ret
=
jQuery
.
merge
(
ret
,
elem
);
ret
=
jQuery
.
merge
(
ret
,
elem
);
}
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment