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
98c79489
Commit
98c79489
authored
Nov 15, 2013
by
Timmy Willison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sizzle
parent
fce6853f
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
13427 additions
and
0 deletions
+13427
-0
.bower.json
bower_modules/sizzle/.bower.json
+33
-0
sizzle.js
bower_modules/sizzle/dist/sizzle.js
+2013
-0
sizzle.min.js
bower_modules/sizzle/dist/sizzle.min.js
+3
-0
sizzle.min.map
bower_modules/sizzle/dist/sizzle.min.map
+1
-0
empty.js
bower_modules/sizzle/test/data/empty.js
+0
-0
mixed_sort.html
bower_modules/sizzle/test/data/mixed_sort.html
+22
-0
testinit.js
bower_modules/sizzle/test/data/testinit.js
+136
-0
index.html
bower_modules/sizzle/test/index.html
+242
-0
jquery.js
bower_modules/sizzle/test/jquery.js
+9597
-0
extending.js
bower_modules/sizzle/test/unit/extending.js
+95
-0
selector.js
bower_modules/sizzle/test/unit/selector.js
+1116
-0
utilities.js
bower_modules/sizzle/test/unit/utilities.js
+169
-0
No files found.
bower_modules/sizzle/.bower.json
0 → 100644
View file @
98c79489
{
"name"
:
"sizzle"
,
"version"
:
"1.10.13"
,
"main"
:
"./dist/sizzle.js"
,
"devDependencies"
:
{
"qunit"
:
"~1.12.0"
,
"benchmark"
:
"~1.0.0"
,
"requirejs"
:
"~2.1.8"
,
"requirejs-domready"
:
"~2.0.1"
,
"requirejs-text"
:
"~2.0.10"
},
"ignore"
:
[
"**/.*"
,
"package.json"
,
"bower.json"
,
"speed"
,
"Makefile"
,
"*.md"
,
"*.txt"
,
"src"
,
"Gruntfile.js"
],
"homepage"
:
"https://github.com/jquery/sizzle"
,
"_release"
:
"1.10.13"
,
"_resolution"
:
{
"type"
:
"version"
,
"tag"
:
"1.10.13"
,
"commit"
:
"7984f2444324137a9481b340c296827b44bd7f6a"
},
"_source"
:
"git://github.com/jquery/sizzle.git"
,
"_target"
:
"1.10.13"
,
"_originalSource"
:
"sizzle"
}
\ No newline at end of file
bower_modules/sizzle/dist/sizzle.js
0 → 100644
View file @
98c79489
This diff is collapsed.
Click to expand it.
bower_modules/sizzle/dist/sizzle.min.js
0 → 100644
View file @
98c79489
This diff is collapsed.
Click to expand it.
bower_modules/sizzle/dist/sizzle.min.map
0 → 100644
View file @
98c79489
This diff is collapsed.
Click to expand it.
bower_modules/sizzle/test/data/empty.js
0 → 100644
View file @
98c79489
bower_modules/sizzle/test/data/mixed_sort.html
0 → 100644
View file @
98c79489
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
<script>
var
QUnit
=
parent
.
QUnit
</script>
<script
src=
"testinit.js"
></script>
<script
src=
"../../dist/sizzle.js"
></script>
</head>
<body>
<script>
var
doc
=
parent
.
document
,
unframed
=
[
doc
.
getElementById
(
"qunit-fixture"
),
doc
.
body
,
doc
.
documentElement
],
framed
=
Sizzle
(
"*"
);
window
.
parent
.
iframeCallback
(
Sizzle
.
uniqueSort
(
unframed
.
concat
(
framed
)
),
framed
.
concat
(
unframed
.
reverse
()
),
"Mixed array was sorted correctly"
);
</script>
</body>
</html>
bower_modules/sizzle/test/data/testinit.js
0 → 100644
View file @
98c79489
var
fireNative
,
jQuery
=
this
.
jQuery
||
"jQuery"
,
// For testing .noConflict()
$
=
this
.
$
||
"$"
,
originaljQuery
=
jQuery
,
original$
=
$
;
(
function
()
{
// Config parameter to force basic code paths
QUnit
.
config
.
urlConfig
.
push
({
id
:
"basic"
,
label
:
"Bypass optimizations"
,
tooltip
:
"Force use of the most basic code by disabling native querySelectorAll; contains; compareDocumentPosition"
});
if
(
QUnit
.
urlParams
.
basic
)
{
document
.
querySelectorAll
=
null
;
document
.
documentElement
.
contains
=
null
;
document
.
documentElement
.
compareDocumentPosition
=
null
;
// Return array of length two to pass assertion
// But support should be false as its not native
document
.
getElementsByClassName
=
function
()
{
return
[
0
,
1
];
};
}
})();
/**
* Returns an array of elements with the given IDs
* @example q("main", "foo", "bar")
* @result [<div id="main">, <span id="foo">, <input id="bar">]
*/
function
q
()
{
var
r
=
[],
i
=
0
;
for
(
;
i
<
arguments
.
length
;
i
++
)
{
r
.
push
(
document
.
getElementById
(
arguments
[
i
]
)
);
}
return
r
;
}
/**
* Asserts that a select matches the given IDs
* @param {String} a - Assertion name
* @param {String} b - Sizzle selector
* @param {String} c - Array of ids to construct what is expected
* @example t("Check for something", "//[a]", ["foo", "baar"]);
* @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baar'
*/
function
t
(
a
,
b
,
c
)
{
var
f
=
Sizzle
(
b
),
s
=
""
,
i
=
0
;
for
(
;
i
<
f
.
length
;
i
++
)
{
s
+=
(
s
&&
","
)
+
'"'
+
f
[
i
].
id
+
'"'
;
}
deepEqual
(
f
,
q
.
apply
(
q
,
c
),
a
+
" ("
+
b
+
")"
);
}
/**
* Add random number to url to stop caching
*
* @example url("data/test.html")
* @result "data/test.html?10538358428943"
*
* @example url("data/test.php?foo=bar")
* @result "data/test.php?foo=bar&10538358345554"
*/
function
url
(
value
)
{
return
value
+
(
/
\?
/
.
test
(
value
)
?
"&"
:
"?"
)
+
new
Date
().
getTime
()
+
""
+
parseInt
(
Math
.
random
()
*
100000
);
}
var
createWithFriesXML
=
function
()
{
var
string
=
'<?xml version="1.0" encoding="UTF-8"?>
\
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
\
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
\
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
\
<soap:Body>
\
<jsconf xmlns="http://www.example.com/ns1">
\
<response xmlns:ab="http://www.example.com/ns2">
\
<meta>
\
<component id="seite1" class="component">
\
<properties xmlns:cd="http://www.example.com/ns3">
\
<property name="prop1">
\
<thing />
\
<value>1</value>
\
</property>
\
<property name="prop2">
\
<thing att="something" />
\
</property>
\
<foo_bar>foo</foo_bar>
\
</properties>
\
</component>
\
</meta>
\
</response>
\
</jsconf>
\
</soap:Body>
\
</soap:Envelope>'
;
return
jQuery
.
parseXML
(
string
);
};
fireNative
=
document
.
createEvent
?
function
(
node
,
type
)
{
var
event
=
document
.
createEvent
(
"HTMLEvents"
);
event
.
initEvent
(
type
,
true
,
true
);
node
.
dispatchEvent
(
event
);
}
:
function
(
node
,
type
)
{
var
event
=
document
.
createEventObject
();
node
.
fireEvent
(
"on"
+
type
,
event
);
};
function
testIframeWithCallback
(
title
,
fileName
,
func
)
{
test
(
title
,
function
()
{
var
iframe
;
stop
();
window
.
iframeCallback
=
function
()
{
var
self
=
this
,
args
=
arguments
;
setTimeout
(
function
()
{
window
.
iframeCallback
=
undefined
;
iframe
.
remove
();
func
.
apply
(
self
,
args
);
func
=
function
()
{};
start
();
},
0
);
};
iframe
=
jQuery
(
"<div/>"
).
css
({
position
:
"absolute"
,
width
:
"500px"
,
left
:
"-600px"
})
.
append
(
jQuery
(
"<iframe/>"
).
attr
(
"src"
,
url
(
"./data/"
+
fileName
)
)
)
.
appendTo
(
"#qunit-fixture"
);
});
};
window
.
iframeCallback
=
undefined
;
function
moduleTeardown
()
{}
bower_modules/sizzle/test/index.html
0 → 100644
View file @
98c79489
This diff is collapsed.
Click to expand it.
bower_modules/sizzle/test/jquery.js
0 → 100644
View file @
98c79489
This diff is collapsed.
Click to expand it.
bower_modules/sizzle/test/unit/extending.js
0 → 100644
View file @
98c79489
module
(
"extending"
,
{
teardown
:
moduleTeardown
});
test
(
"custom pseudos"
,
function
()
{
expect
(
6
);
Sizzle
.
selectors
.
filters
.
foundation
=
Sizzle
.
selectors
.
filters
.
root
;
deepEqual
(
Sizzle
(
":foundation"
),
[
document
.
documentElement
],
"Copy element filter with new name"
);
delete
Sizzle
.
selectors
.
filters
.
foundation
;
Sizzle
.
selectors
.
setFilters
.
primary
=
Sizzle
.
selectors
.
setFilters
.
first
;
t
(
"Copy set filter with new name"
,
"div:primary"
,
[
"qunit"
]
);
delete
Sizzle
.
selectors
.
setFilters
.
primary
;
Sizzle
.
selectors
.
filters
.
aristotlean
=
Sizzle
.
selectors
.
createPseudo
(
function
()
{
return
function
(
elem
)
{
return
!!
elem
.
id
;
};
});
t
(
"Custom element filter"
,
"#foo :aristotlean"
,
[
"sndp"
,
"en"
,
"yahoo"
,
"sap"
,
"anchor2"
,
"simon"
]
);
delete
Sizzle
.
selectors
.
filters
.
aristotlean
;
Sizzle
.
selectors
.
filters
.
endswith
=
Sizzle
.
selectors
.
createPseudo
(
function
(
text
)
{
return
function
(
elem
)
{
return
Sizzle
.
getText
(
elem
).
slice
(
-
text
.
length
)
===
text
;
};
});
t
(
"Custom element filter with argument"
,
"a:endswith(ogle)"
,
[
"google"
]
);
delete
Sizzle
.
selectors
.
filters
.
endswith
;
Sizzle
.
selectors
.
setFilters
.
second
=
Sizzle
.
selectors
.
createPseudo
(
function
()
{
return
Sizzle
.
selectors
.
createPseudo
(
function
(
seed
,
matches
)
{
if
(
seed
[
1
]
)
{
matches
[
1
]
=
seed
[
1
];
seed
[
1
]
=
false
;
}
});
});
t
(
"Custom set filter"
,
"#qunit-fixture p:second"
,
[
"ap"
]
);
delete
Sizzle
.
selectors
.
filters
.
second
;
Sizzle
.
selectors
.
setFilters
.
slice
=
Sizzle
.
selectors
.
createPseudo
(
function
(
argument
)
{
var
bounds
=
argument
.
split
(
":"
);
return
Sizzle
.
selectors
.
createPseudo
(
function
(
seed
,
matches
)
{
var
i
=
bounds
[
1
];
// Match elements found at the specified indexes
while
(
--
i
>=
bounds
[
0
]
)
{
if
(
seed
[
i
]
)
{
matches
[
i
]
=
seed
[
i
];
seed
[
i
]
=
false
;
}
}
});
});
t
(
"Custom set filter with argument"
,
"#qunit-fixture p:slice(1:3)"
,
[
"ap"
,
"sndp"
]
);
delete
Sizzle
.
selectors
.
filters
.
slice
;
});
test
(
"backwards-compatible custom pseudos"
,
function
()
{
expect
(
3
);
Sizzle
.
selectors
.
filters
.
icontains
=
function
(
elem
,
i
,
match
)
{
return
Sizzle
.
getText
(
elem
).
toLowerCase
().
indexOf
(
(
match
[
3
]
||
""
).
toLowerCase
()
)
>
-
1
;
};
t
(
"Custom element filter with argument"
,
"a:icontains(THIS BLOG ENTRY)"
,
[
"simon1"
]
);
delete
Sizzle
.
selectors
.
filters
.
icontains
;
Sizzle
.
selectors
.
setFilters
.
podium
=
function
(
elements
,
argument
)
{
var
count
=
argument
==
null
||
argument
===
""
?
3
:
+
argument
;
return
elements
.
slice
(
0
,
count
);
};
// Using TAG as the first token here forces this setMatcher into a fail state
// Where the descendent combinator was lost
t
(
"Custom setFilter"
,
"form#form :PODIUM"
,
[
"label-for"
,
"text1"
,
"text2"
]
);
t
(
"Custom setFilter with argument"
,
"#form input:Podium(1)"
,
[
"text1"
]
);
delete
Sizzle
.
selectors
.
setFilters
.
podium
;
});
test
(
"custom attribute getters"
,
function
()
{
expect
(
2
);
var
original
=
Sizzle
.
selectors
.
attrHandle
.
hreflang
,
selector
=
"a:contains('mark')[hreflang='http://diveintomark.org/en']"
;
Sizzle
.
selectors
.
attrHandle
.
hreflang
=
function
(
elem
,
name
)
{
var
href
=
elem
.
getAttribute
(
"href"
),
lang
=
elem
.
getAttribute
(
name
);
return
lang
&&
(
href
+
lang
);
};
deepEqual
(
Sizzle
(
selector
,
createWithFriesXML
()),
[],
"Custom attrHandle (preferred document)"
);
t
(
"Custom attrHandle (preferred document)"
,
selector
,
[
"mark"
]
);
Sizzle
.
selectors
.
attrHandle
.
hreflang
=
original
;
});
bower_modules/sizzle/test/unit/selector.js
0 → 100644
View file @
98c79489
This diff is collapsed.
Click to expand it.
bower_modules/sizzle/test/unit/utilities.js
0 → 100644
View file @
98c79489
module
(
"utilities"
,
{
teardown
:
moduleTeardown
});
function
testAttr
(
doc
)
{
expect
(
9
);
var
el
;
if
(
doc
)
{
// XML
el
=
doc
.
createElement
(
"input"
);
el
.
setAttribute
(
"type"
,
"checkbox"
);
}
else
{
// Set checked on creation by creating with a fragment
// See http://jsfiddle.net/8sVgA/1/show/light in oldIE
el
=
jQuery
(
"<input type='checkbox' checked='checked' />"
)[
0
];
}
// Set it again for good measure
el
.
setAttribute
(
"checked"
,
"checked"
);
el
.
setAttribute
(
"id"
,
"id"
);
el
.
setAttribute
(
"value"
,
"on"
);
strictEqual
(
Sizzle
.
attr
(
el
,
"nonexistent"
),
null
,
"nonexistent"
);
strictEqual
(
Sizzle
.
attr
(
el
,
"id"
),
"id"
,
"existent"
);
strictEqual
(
Sizzle
.
attr
(
el
,
"value"
),
"on"
,
"value"
);
strictEqual
(
Sizzle
.
attr
(
el
,
"checked"
),
"checked"
,
"boolean"
);
strictEqual
(
Sizzle
.
attr
(
el
,
"href"
),
null
,
"interpolation risk"
);
strictEqual
(
Sizzle
.
attr
(
el
,
"constructor"
),
null
,
"Object.prototype property
\"
constructor
\"
(negative)"
);
strictEqual
(
Sizzle
.
attr
(
el
,
"watch"
),
null
,
"Gecko Object.prototype property
\"
watch
\"
(negative)"
);
el
.
setAttribute
(
"constructor"
,
"foo"
);
el
.
setAttribute
(
"watch"
,
"bar"
);
strictEqual
(
Sizzle
.
attr
(
el
,
"constructor"
),
"foo"
,
"Object.prototype property
\"
constructor
\"
"
);
strictEqual
(
Sizzle
.
attr
(
el
,
"watch"
),
"bar"
,
"Gecko Object.prototype property
\"
watch
\"
"
);
}
test
(
"Sizzle.attr (HTML)"
,
function
()
{
testAttr
();
});
test
(
"Sizzle.attr (XML)"
,
function
()
{
testAttr
(
jQuery
.
parseXML
(
"<root/>"
)
);
});
test
(
"Sizzle.contains"
,
function
()
{
expect
(
16
);
var
container
=
document
.
getElementById
(
"nonnodes"
),
element
=
container
.
firstChild
,
text
=
element
.
nextSibling
,
nonContained
=
container
.
nextSibling
,
detached
=
document
.
createElement
(
"a"
);
ok
(
element
&&
element
.
nodeType
===
1
,
"preliminary: found element"
);
ok
(
text
&&
text
.
nodeType
===
3
,
"preliminary: found text"
);
ok
(
nonContained
,
"preliminary: found non-descendant"
);
ok
(
Sizzle
.
contains
(
container
,
element
),
"child"
);
ok
(
Sizzle
.
contains
(
container
.
parentNode
,
element
),
"grandchild"
);
ok
(
Sizzle
.
contains
(
container
,
text
),
"text child"
);
ok
(
Sizzle
.
contains
(
container
.
parentNode
,
text
),
"text grandchild"
);
ok
(
!
Sizzle
.
contains
(
container
,
container
),
"self"
);
ok
(
!
Sizzle
.
contains
(
element
,
container
),
"parent"
);
ok
(
!
Sizzle
.
contains
(
container
,
nonContained
),
"non-descendant"
);
ok
(
!
Sizzle
.
contains
(
container
,
document
),
"document"
);
ok
(
!
Sizzle
.
contains
(
container
,
document
.
documentElement
),
"documentElement (negative)"
);
ok
(
!
Sizzle
.
contains
(
container
,
null
),
"Passing null does not throw an error"
);
ok
(
Sizzle
.
contains
(
document
,
document
.
documentElement
),
"documentElement (positive)"
);
ok
(
Sizzle
.
contains
(
document
,
element
),
"document container (positive)"
);
ok
(
!
Sizzle
.
contains
(
document
,
detached
),
"document container (negative)"
);
});
if
(
jQuery
(
"<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='1' width='1'><g/></svg>"
)[
0
].
firstChild
)
{
test
(
"Sizzle.contains in SVG (jQuery #10832)"
,
function
()
{
expect
(
4
);
var
svg
=
jQuery
(
"<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='1' width='1'>"
+
"<g><circle cx='1' cy='1' r='1' /></g>"
+
"</svg>"
).
appendTo
(
"#qunit-fixture"
)[
0
];
ok
(
Sizzle
.
contains
(
svg
,
svg
.
firstChild
),
"root child"
);
ok
(
Sizzle
.
contains
(
svg
.
firstChild
,
svg
.
firstChild
.
firstChild
),
"element child"
);
ok
(
Sizzle
.
contains
(
svg
,
svg
.
firstChild
.
firstChild
),
"root granchild"
);
ok
(
!
Sizzle
.
contains
(
svg
.
firstChild
.
firstChild
,
svg
.
firstChild
),
"parent (negative)"
);
});
}
test
(
"Sizzle.uniqueSort"
,
function
()
{
expect
(
14
);
function
Arrayish
(
arr
)
{
var
i
=
this
.
length
=
arr
.
length
;
while
(
i
--
)
{
this
[
i
]
=
arr
[
i
];
}
}
Arrayish
.
prototype
=
{
slice
:
[].
slice
,
sort
:
[].
sort
,
splice
:
[].
splice
};
var
i
,
tests
,
detached
=
[],
body
=
document
.
body
,
fixture
=
document
.
getElementById
(
"qunit-fixture"
),
detached1
=
document
.
createElement
(
"p"
),
detached2
=
document
.
createElement
(
"ul"
),
detachedChild
=
detached1
.
appendChild
(
document
.
createElement
(
"a"
)
),
detachedGrandchild
=
detachedChild
.
appendChild
(
document
.
createElement
(
"b"
)
);
for
(
i
=
0
;
i
<
12
;
i
++
)
{
detached
.
push
(
document
.
createElement
(
"li"
)
);
detached
[
i
].
id
=
"detached"
+
i
;
detached2
.
appendChild
(
document
.
createElement
(
"li"
)
).
id
=
"detachedChild"
+
i
;
}
tests
=
{
"Empty"
:
{
input
:
[],
expected
:
[]
},
"Single-element"
:
{
input
:
[
fixture
],
expected
:
[
fixture
]
},
"No duplicates"
:
{
input
:
[
fixture
,
body
],
expected
:
[
body
,
fixture
]
},
"Duplicates"
:
{
input
:
[
body
,
fixture
,
fixture
,
body
],
expected
:
[
body
,
fixture
]
},
"Detached"
:
{
input
:
detached
.
slice
(
0
),
expected
:
detached
.
slice
(
0
)
},
"Detached children"
:
{
input
:
[
detached2
.
childNodes
[
0
],
detached2
.
childNodes
[
1
],
detached2
.
childNodes
[
2
],
detached2
.
childNodes
[
3
]
],
expected
:
[
detached2
.
childNodes
[
0
],
detached2
.
childNodes
[
1
],
detached2
.
childNodes
[
2
],
detached2
.
childNodes
[
3
]
]
},
"Attached/detached mixture"
:
{
input
:
[
detached1
,
fixture
,
detached2
,
document
,
detachedChild
,
body
,
detachedGrandchild
],
expected
:
[
document
,
body
,
fixture
],
length
:
3
}
};
jQuery
.
each
(
tests
,
function
(
label
,
test
)
{
var
length
=
test
.
length
||
test
.
input
.
length
;
deepEqual
(
Sizzle
.
uniqueSort
(
test
.
input
).
slice
(
0
,
length
),
test
.
expected
,
label
+
" (array)"
);
deepEqual
(
Sizzle
.
uniqueSort
(
new
Arrayish
(
test
.
input
)
).
slice
(
0
,
length
),
test
.
expected
,
label
+
" (quasi-array)"
);
});
});
testIframeWithCallback
(
"Sizzle.uniqueSort works cross-window (jQuery #14381)"
,
"mixed_sort.html"
,
deepEqual
);
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