Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
g1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
76
Issues
76
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cto
g1
Commits
26e33641
Commit
26e33641
authored
Feb 16, 2019
by
Karmanya Aggarwal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some tests added
parent
6e93b42f
Pipeline
#77004
passed with stage
in 2 minutes and 43 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
docs/urlchange.md
docs/urlchange.md
+4
-0
test/test-urlchange.html
test/test-urlchange.html
+21
-0
No files found.
docs/urlchange.md
View file @
26e33641
...
...
@@ -52,6 +52,10 @@ Examples:
-
When the URL changes from
`#a`
to
`#b`
, it triggers 2 events on
`window`
:
-
`.on('#', function(e) { e.hash.pathname == 'b' }`
-
`.on('#/', function(e, val) { val == 'b' && e.old == 'a' }`
-
Combinations of keys can be listened to simultaneously
-
`.on('#?x #?y', function(e){})`
will only be triggered if both x and y change
-
When the hashkey is reset,
`location.hash=''`
-
`.on('#', function(e){})`
as the location.hash is now
`{}`
## $.urlchange events
...
...
test/test-urlchange.html
View file @
26e33641
...
...
@@ -89,6 +89,27 @@
window
.
location
.
hash
=
'
#?x=1&y=2
'
})
tape
(
'
clearing x should still trigger an event
'
,
function
(
t
)
{
reset
(
'
#?x=1
'
)
t
.
plan
(
2
)
// One less than no. of tests. #?x.test should not be fired
$
(
window
).
one
(
'
#?x
'
,
function
(
e
,
val
)
{
t
.
deepEqual
(
e
.
hash
.
searchList
,
{})
t
.
deepEqual
(
e
.
old
.
searchList
,
{
'
x
'
:
[
'
1
'
]})
})
window
.
location
.
hash
=
''
})
tape
(
'
Adding #?abc=1&xyz=2 triggers on both abc and xyz events
'
,
function
(
t
)
{
reset
(
'
#?abc=1&xyz=1
'
)
t
.
plan
(
3
)
// One less than no. of tests. #?x.test should not be fired
$
(
window
).
one
(
'
#?abc #?xyz
'
,
function
(
e
,
val
)
{
t
.
equal
(
val
,
'
2
'
)
t
.
deepEqual
(
e
.
hash
.
searchList
,
{
'
abc
'
:
[
'
1
'
],
'
xyz
'
:
[
'
2
'
]
})
t
.
deepEqual
(
e
.
old
.
searchList
,
{
'
abc
'
:
[
'
1
'
],
'
xyz
'
:
[
'
1
'
]
})
})
window
.
location
.
hash
=
'
#?abc=1&xyz=2
'
})
tape
(
'
#a?x=1&y=2&z=3 -> #b?x=1&x=2&y=3
'
,
function
(
t
)
{
reset
(
'
#a?x=1&y=2&z=3
'
)
t
.
plan
(
18
)
...
...
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