Skip to content

Commit 887c399

Browse files
authored
Adds components to queues (#320)
* adds components to queues * removing double parent update test
1 parent 074c4e5 commit 887c399

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

can-component.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var canLog = require('can-log');
3030
var canDev = require('can-log/dev/dev');
3131
var assign = require('can-assign');
3232
var ObservationRecorder = require("can-observation-recorder");
33+
var queues = require("can-queues");
3334
require('can-view-model');
3435

3536
// DefineList must be imported so Arrays on the ViewModel
@@ -330,14 +331,28 @@ var Component = Construct.extend(
330331
this.renderer = stache(viewName, this.renderer);
331332
}
332333

333-
// Register this component to be created when its `tag` is found.
334-
viewCallbacks.tag(this.prototype.tag, function(el, tagData) {
334+
var renderComponent = function(el, tagData) {
335335
// Check if a symbol already exists on the element; if it does, then
336336
// a new instance of the component has already been created
337337
if (el[createdByCanComponentSymbol] === undefined) {
338338
new self(el, tagData);
339339
}
340-
});
340+
};
341+
342+
//!steal-remove-start
343+
if (process.env.NODE_ENV !== 'production') {
344+
Object.defineProperty(renderComponent, "name",{
345+
value: "render <"+this.prototype.tag+">",
346+
configurable: true
347+
});
348+
renderComponent = queues.runAsTask(renderComponent, function(el, tagData) {
349+
return ["Rendering", el, "with",tagData.scope];
350+
});
351+
}
352+
//!steal-remove-end
353+
354+
// Register this component to be created when its `tag` is found.
355+
viewCallbacks.tag(this.prototype.tag, renderComponent);
341356
}
342357
}
343358
}, {

test/component-viewmodel-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ helpers.makeTests("can-component viewModels", function(){
453453

454454

455455
test("conditional attributes (#2077)", function(){
456-
456+
457457
Component.extend({
458458
tag: 'some-comp',
459459
ViewModel: DefineMap.extend({ seal: false }, {})

0 commit comments

Comments
 (0)