Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
renderjs
Commits
95726c33
Commit
95726c33
authored
Feb 24, 2017
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent calling onStateChange callback if not needed
parent
32a5a8ef
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
renderjs.js
renderjs.js
+1
-1
test/renderjs_test.js
test/renderjs_test.js
+24
-0
No files found.
renderjs.js
View file @
95726c33
...
@@ -608,7 +608,6 @@
...
@@ -608,7 +608,6 @@
modified
=
true
;
modified
=
true
;
}
else
{
}
else
{
modification_dict
=
{};
modification_dict
=
{};
this
.
__modification_dict
=
modification_dict
;
}
}
for
(
key
in
state_dict
)
{
for
(
key
in
state_dict
)
{
if
(
state_dict
.
hasOwnProperty
(
key
)
&&
if
(
state_dict
.
hasOwnProperty
(
key
)
&&
...
@@ -619,6 +618,7 @@
...
@@ -619,6 +618,7 @@
}
}
}
}
if
(
modified
&&
this
.
__state_change_callback
!==
undefined
)
{
if
(
modified
&&
this
.
__state_change_callback
!==
undefined
)
{
this
.
__modification_dict
=
modification_dict
;
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
context
.
__state_change_callback
(
modification_dict
);
return
context
.
__state_change_callback
(
modification_dict
);
...
...
test/renderjs_test.js
View file @
95726c33
...
@@ -1328,6 +1328,30 @@
...
@@ -1328,6 +1328,30 @@
});
});
});
});
test
(
'
do not trigger onStateChange if no changed keys twice
'
,
function
()
{
var
gadget
=
new
RenderJSGadget
(),
callback_called
=
false
;
gadget
.
state
=
{};
gadget
.
__state_change_callback
=
function
()
{
callback_called
=
true
;
};
stop
();
gadget
.
changeState
({})
.
then
(
function
()
{
ok
(
!
callback_called
);
return
gadget
.
changeState
({});
})
.
then
(
function
()
{
ok
(
!
callback_called
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
'
accumulate modification_dict on onStateChange error
'
,
function
()
{
test
(
'
accumulate modification_dict on onStateChange error
'
,
function
()
{
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
expect
(
13
);
expect
(
13
);
...
...
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