我在$ timeout内有一段代码,执行了一个Promise。当我为此编写单元测试时,我使用$ timeout.flush()并且可以进入$ timeout块。然后解决了promise(因为$ timeout在内部调用了$ scope。$ apply()),但是在方法代码完成并冒出茉莉花之后,我得到了错误TypeError:无法读取未定义的属性'$$ nextSibling'。其他人曾经经历过吗?
控制器代码:
$scope.timeoutFunction = function(){
$timeout(function () {
$scope.callFunction().then(function () {
callAnotherFunction();
});
}, 0);
}
Run Code Online (Sandbox Code Playgroud)
单元测试代码:
$scope.timeoutFunction();
scope.$digest(); // not needed
$timeout.flush(); // even tried $timeout.flush(0);
Run Code Online (Sandbox Code Playgroud)
另外,如果我模拟超时是一个回调函数,它的工作原理。例:
function mockedTimeout() {
arguments[0]();
}
$timeout = mockedTimeout;
Run Code Online (Sandbox Code Playgroud)
然后,我们只使用$ scope。$ digest来调用promise,超时立即运行。可能是尖角虫吗?
完整的错误堆栈:
TypeError: Cannot read property '$$nextSibling' of undefined
at n.$get.n.$digest (http://localhost:51679/referenceFile?path=D:\development\Projects\WebSite\Scripts\Libs\Angular\angular.min.js:124:101)
at n.$get.n.$apply (http://localhost:51679/referenceFile?path=D:\development\Projects\WebSite\Scripts\Libs\Angular\angular.min.js:126:293)
at Object.fn (http://localhost:51679/referenceFile?path=D:\development\Projects\WebSite\Scripts\Libs\Angular\angular.min.js:139:3)
at Function.angular.mock.$Browser.self.defer.flush (http://localhost:51679/referenceFile?path=D:\development\Projects\WebSite\Scripts\TDD\angular-mocks.js:127:42)
at Function.angular.mock.$TimeoutDecorator.$delegate.flush (http://localhost:51679/referenceFile?path=D:\development\Projects\WebSite\Scripts\TDD\angular-mocks.js:1732:28)
at null.<anonymous> (http://localhost:51679/Tests.js:254:18)
at jasmine.Block.execute (http://localhost:51679/referenceFile?path=D:\development\Projects\WebSite\Scripts\jasmine.js:1064:17)
at jasmine.Queue.next_ (http://localhost:51679/referenceFile?path=D:\development\Projects\WebSite\Scripts\jasmine.js:2096:31)
at jasmine.Queue.start …Run Code Online (Sandbox Code Playgroud) 我有最新的 ckeditor 版本 4.5.7,带有拖放 API,我有一个情况,我需要将一个小部件从一个编辑器拖放到另一个编辑器。正如这张票所说,建议的功能是静默失败并且不执行任何操作。
就我而言,如果将小部件拖动到不同的编辑器,则需要复制小部件;如果将小部件拖动到同一编辑器中,则需要移动小部件。第二种情况已经在工作
关于如何做到这一点有什么想法吗?
editor.on( 'contentDom', function() {
var dropTarget = CKEDITOR.plugins.clipboard.getDropTarget( editor );
editor.editable().attachListener( dropTarget, 'drop', function( evt ) {
// The target may be some element inside the draggable div (e.g. the image), so get the div.h-card.
var target = evt.data.getTarget().getAscendant( 'div', true );
// Initialization of CKEditor data transfer facade is a necessary step to extend and unify native
// browser capabilities. For instance, Internet Explorer does not support any other data …Run Code Online (Sandbox Code Playgroud) 有没有办法重新渲染布局,同时忽略一些将通过自定义动画删除的节点?
cy.layout(
{
name: "dagre",
rankDir: "LR",
spacingFactor: 1,
animate: true,
animationDuration: 5000,
rankSep: 200,
}).run();
setTimeout(() => {
cy.elements()[2].animate(
{
style: {
opacity: 0
}
},
{
duration: 5000
);
}, 5000);
cy.layout(
{
name: "dagre",
rankDir: "LR",
spacingFactor: 1,
animate: true,
animationDuration: 5000,
rankSep: 200,
}).run();
Run Code Online (Sandbox Code Playgroud)
我想在重新渲染布局时过滤正在动画的节点(不包括该节点)