Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rsvp.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
rsvp.js
Commits
60f83a3b
Commit
60f83a3b
authored
Mar 30, 2013
by
Stefan Penner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fix] promises could be changed after reject/resolve
parent
71a9de8d
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
20 deletions
+30
-20
browser/rsvp.js
browser/rsvp.js
+6
-5
browser/rsvp.min.js
browser/rsvp.min.js
+1
-1
browser/rsvp/promise.amd.js
browser/rsvp/promise.amd.js
+6
-5
lib/rsvp/promise.js
lib/rsvp/promise.js
+6
-7
tests/extension-tests.js
tests/extension-tests.js
+11
-2
No files found.
browser/rsvp.js
View file @
60f83a3b
...
...
@@ -372,7 +372,8 @@ define("rsvp/promise",
var
noop
=
function
()
{};
var
Promise
=
function
(
resolver
)
{
var
promise
=
this
;
var
promise
=
this
,
resolved
=
false
;
if
(
typeof
resolver
!==
'
function
'
)
{
throw
new
TypeError
(
'
You must pass a resolver function as the sole argument to the promise constructor
'
);
...
...
@@ -383,15 +384,15 @@ define("rsvp/promise",
}
var
resolvePromise
=
function
(
value
)
{
if
(
resolved
)
{
return
;
}
resolved
=
true
;
resolve
(
promise
,
value
);
resolvePromise
=
noop
;
rejectPromise
=
noop
;
};
var
rejectPromise
=
function
(
value
)
{
if
(
resolved
)
{
return
;
}
resolved
=
true
;
reject
(
promise
,
value
);
resolvePromise
=
noop
;
rejectPromise
=
noop
;
};
this
.
on
(
'
promise:resolved
'
,
function
(
event
)
{
...
...
browser/rsvp.min.js
View file @
60f83a3b
This diff is collapsed.
Click to expand it.
browser/rsvp/promise.amd.js
View file @
60f83a3b
...
...
@@ -8,7 +8,8 @@ define(
var
noop
=
function
()
{};
var
Promise
=
function
(
resolver
)
{
var
promise
=
this
;
var
promise
=
this
,
resolved
=
false
;
if
(
typeof
resolver
!==
'
function
'
)
{
throw
new
TypeError
(
'
You must pass a resolver function as the sole argument to the promise constructor
'
);
...
...
@@ -19,15 +20,15 @@ define(
}
var
resolvePromise
=
function
(
value
)
{
if
(
resolved
)
{
return
;
}
resolved
=
true
;
resolve
(
promise
,
value
);
resolvePromise
=
noop
;
rejectPromise
=
noop
;
};
var
rejectPromise
=
function
(
value
)
{
if
(
resolved
)
{
return
;
}
resolved
=
true
;
reject
(
promise
,
value
);
resolvePromise
=
noop
;
rejectPromise
=
noop
;
};
this
.
on
(
'
promise:resolved
'
,
function
(
event
)
{
...
...
lib/rsvp/promise.js
View file @
60f83a3b
import
{
config
}
from
"
rsvp/config
"
;
import
{
EventTarget
}
from
"
rsvp/events
"
;
var
noop
=
function
()
{};
var
Promise
=
function
(
resolver
)
{
var
promise
=
this
;
var
promise
=
this
,
resolved
=
false
;
if
(
typeof
resolver
!==
'
function
'
)
{
throw
new
TypeError
(
'
You must pass a resolver function as the sole argument to the promise constructor
'
);
...
...
@@ -15,15 +14,15 @@ var Promise = function(resolver) {
}
var
resolvePromise
=
function
(
value
)
{
if
(
resolved
)
{
return
;
}
resolved
=
true
;
resolve
(
promise
,
value
);
resolvePromise
=
noop
;
rejectPromise
=
noop
;
};
var
rejectPromise
=
function
(
value
)
{
if
(
resolved
)
{
return
;
}
resolved
=
true
;
reject
(
promise
,
value
);
resolvePromise
=
noop
;
rejectPromise
=
noop
;
};
this
.
on
(
'
promise:resolved
'
,
function
(
event
)
{
...
...
tests/extension-tests.js
View file @
60f83a3b
...
...
@@ -705,12 +705,21 @@ describe("RSVP extensions", function() {
assert
(
calledResolved
===
0
,
'
never resolved
'
);
assert
(
calledRejected
===
1
,
'
rejected only once
'
);
assert
(
error
===
expectedError
,
'
rejected promise with x
'
);
done
();
});
rejector
(
expectedError
);
rejector
(
expectedError
);
resolver
();
rejector
(
'
foo
'
);
resolver
(
'
bar
'
);
resolver
(
'
baz
'
);
setTimeout
(
function
(){
assert
(
calledRejected
===
1
,
'
only rejected once
'
);
assert
(
calledResolved
===
0
,
'
never resolved
'
);
done
();
},
50
);
});
describe
(
"
2.3.4 If calling then throws an exception e
"
,
function
(){
...
...
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