Skip to content

Commit

Permalink
Added custom debug messages for async view init, wrong
Browse files Browse the repository at this point in the history
[]-observable-reset and usage of not comment-ready data-queries in
comments.
  • Loading branch information
Joscha Rohmann authored and Kanaye committed Sep 10, 2016
1 parent bdcd089 commit bccf7ba
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/mvc/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,14 @@ define([
if (arguments.length == 1) {
return this._views[name];
}

if (this._started) {
// @if DEBUG
blocks.debug.throwMessage('Views can not be constructed / added after the application has been started. Try to add your views sync.', __DEBUG_METHOD, 'Error');
// @endif
return;
}

if (blocks.isString(prototype)) {
this._viewPrototypes[prototype] = this._createView(nestedViewPrototype);
nestedViewPrototype.options.parentView = name;
Expand Down
4 changes: 3 additions & 1 deletion src/query/DomQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ define([

if (VirtualElement.Is(element)) {
if (VirtualComment.Is(element) && !method.supportsComments) {
// TODO: Should throw debug message
// @if DEBUG
blocks.debug.throwMessage('data-query ' + methods[i].name + ' does not support to be executed as on a comment.', blocks.debug.queries[methods[i].name], 'Error');
// @endif
continue;
}

Expand Down
11 changes: 9 additions & 2 deletions src/query/observable.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ define([
} else if (!blocks.equals(value, currentValue, false) && Events.trigger(observable, 'changing', value, currentValue) !== false) {
observable.update = blocks.noop;
if (!observable._dependencyType) {
if (blocks.isArray(currentValue) && blocks.isArray(value) && observable.reset) {
if (blocks.isArray(currentValue) && (blocks.isArray(value) || !value) && observable.reset) {
observable.reset(value);
} else {
} else if (!blocks.isArray(currentValue) && !observable.reset) {
observable.__value__ = value;
}
} else if (observable._dependencyType == 2) {
Expand Down Expand Up @@ -368,6 +368,13 @@ define([

array = blocks.unwrap(array);

if (!blocks.isArray(array) && !!array) {
//@if DEBUG
blocks.debug.throwMessage('Array-Observables can not be reseted to a non array type! Reset got aborted.', __DEBUG_METHOD, 'Warning');
//@endif
return;
}

var current = this.__value__;
var chunkManager = this._chunkManager;
var addCount = Math.max(array.length - current.length, 0);
Expand Down

0 comments on commit bccf7ba

Please sign in to comment.