can-map-define
Advanced tools
Comparing version 3.1.2 to 4.0.0
@@ -13,3 +13,3 @@ /* jshint asi: false */ | ||
// remove, type, default | ||
test('basics set', function() { | ||
QUnit.test('basics set', function() { | ||
var Defined = CanMap.extend({ | ||
@@ -47,3 +47,3 @@ define: { | ||
test("basics remove", function() { | ||
QUnit.test("basics remove", function() { | ||
var ViewModel = CanMap.extend({ | ||
@@ -107,3 +107,4 @@ define: { | ||
test("basics get", function() { | ||
QUnit.test("basics get", function(assert) { | ||
var done = assert.async(); | ||
@@ -120,9 +121,5 @@ var Person = CanMap.extend({ | ||
var p = new Person({ | ||
first: "Justin", | ||
last: "Meyer" | ||
}); | ||
var p = new Person({ first: "Justin", last: "Meyer" }); | ||
assert.equal(p.attr("fullName"), "Justin Meyer", "sync getter works"); | ||
equal(p.attr("fullName"), "Justin Meyer", "sync getter works"); | ||
var Adder = CanMap.extend({ | ||
@@ -141,29 +138,30 @@ define: { | ||
var a = new Adder({ | ||
num: 1 | ||
}), | ||
callbackVals = [ | ||
[2, undefined, function() { | ||
var callbackCount = 0; | ||
var a = new Adder({ num: 1 }); | ||
var callbackVals = [ | ||
{ | ||
newVal: 2, | ||
oldVal: undefined, | ||
next: function next() { | ||
a.attr("num", 2); | ||
}], | ||
[3, 2, function() { | ||
start(); | ||
}] | ||
], | ||
callbackCount = 0; | ||
} | ||
}, | ||
{ | ||
newVal: 3, | ||
oldVal: 2, | ||
next: done | ||
} | ||
]; | ||
a.bind("more", function(ev, newVal, oldVal) { | ||
var vals = callbackVals[callbackCount++]; | ||
equal(newVal, vals[0], "newVal is correct"); | ||
equal(a.attr("more"), vals[0], "attr value is correct"); | ||
equal(oldVal, vals[1], "oldVal is correct"); | ||
setTimeout(vals[2], 10); | ||
assert.equal(newVal, vals.newVal, "newVal is correct"); | ||
assert.equal(a.attr("more"), vals.newVal, "attr value is correct"); | ||
assert.equal(oldVal, vals.oldVal, "oldVal is correct"); | ||
setTimeout(vals.next, 10); | ||
}); | ||
stop(); | ||
}); | ||
test("basic type", function() { | ||
QUnit.test("basic type", function() { | ||
@@ -217,3 +215,3 @@ expect(6); | ||
test("basic Type", function() { | ||
QUnit.test("basic Type", function() { | ||
var Foo = function(name) { | ||
@@ -247,3 +245,3 @@ this.name = name; | ||
test("type converters", function() { | ||
QUnit.test("type converters", function() { | ||
@@ -302,3 +300,3 @@ var Typer = CanMap.extend({ | ||
test("basics value", function() { | ||
QUnit.test("basics value", function() { | ||
var Typer = CanMap.extend({ | ||
@@ -334,3 +332,3 @@ define: { | ||
test("basics Value", function() { | ||
QUnit.test("basics Value", function() { | ||
@@ -355,3 +353,3 @@ var Typer = CanMap.extend({ | ||
test("setter with no arguments and returns undefined does the default behavior, the setter is for side effects only", function() { | ||
QUnit.test("setter with no arguments and returns undefined does the default behavior, the setter is for side effects only", function() { | ||
@@ -380,3 +378,3 @@ var Typer = CanMap.extend({ | ||
test("type happens before the set", function() { | ||
QUnit.test("type happens before the set", function() { | ||
var MyMap = CanMap.extend({ | ||
@@ -400,3 +398,3 @@ define: { | ||
test("getter and setter work", function() { | ||
QUnit.test("getter and setter work", function() { | ||
expect(5); | ||
@@ -437,3 +435,3 @@ var Paginate = CanMap.extend({ | ||
test("getter with initial value", function() { | ||
QUnit.test("getter with initial value", function() { | ||
@@ -458,2 +456,3 @@ var comp = compute(1); | ||
var g = new Grabber(); | ||
// This assertion doesn't mean much. It's mostly testing | ||
@@ -466,3 +465,3 @@ // that there were no errors. | ||
test("serialize basics", function() { | ||
QUnit.test("serialize basics", function() { | ||
var MyMap = CanMap.extend({ | ||
@@ -481,3 +480,3 @@ define: { | ||
var ids = []; | ||
this.attr('locations').each(function(location) { | ||
this.attr('locations').forEach(function(location) { | ||
ids.push(location.id); | ||
@@ -529,3 +528,3 @@ }); | ||
test("serialize context", function() { | ||
QUnit.test("serialize context", function() { | ||
var context, serializeContext; | ||
@@ -554,3 +553,3 @@ var MyMap = CanMap.extend({ | ||
test("methods contexts", function() { | ||
QUnit.test("methods contexts", function() { | ||
var contexts = {}; | ||
@@ -602,3 +601,3 @@ var MyMap = CanMap.extend({ | ||
test("value generator is not called if default passed", function() { | ||
QUnit.test("value generator is not called if default passed", function() { | ||
var TestMap = CanMap.extend({ | ||
@@ -621,3 +620,3 @@ define: { | ||
test("Value generator can read other properties", function() { | ||
QUnit.test("Value generator can read other properties", function() { | ||
var Map = CanMap.extend({ | ||
@@ -701,3 +700,3 @@ letters: 'ABC', | ||
test('default behaviors with "*" work for attributes', function() { | ||
QUnit.test('default behaviors with "*" work for attributes', function() { | ||
expect(9); | ||
@@ -742,3 +741,3 @@ var DefaultMap = CanMap.extend({ | ||
test('models properly serialize with default behaviors', function() { | ||
QUnit.test('models properly serialize with default behaviors', function() { | ||
var DefaultMap = CanMap.extend({ | ||
@@ -769,3 +768,3 @@ define: { | ||
test("nested define", function() { | ||
QUnit.test("nested define", function() { | ||
var nailedIt = 'Nailed it'; | ||
@@ -822,3 +821,3 @@ var Example = CanMap.extend({}, { | ||
test('Can make an attr alias a compute (#1470)', 9, function() { | ||
QUnit.test('Can make an attr alias a compute (#1470)', 9, function() { | ||
var computeValue = compute(1); | ||
@@ -890,3 +889,3 @@ var GetMap = CanMap.extend({ | ||
test('setting a value of a property with type "compute" triggers change events', function() { | ||
QUnit.test('setting a value of a property with type "compute" triggers change events', function() { | ||
@@ -935,3 +934,3 @@ var handler; | ||
test('replacing the compute on a property with type "compute"', function() { | ||
QUnit.test('replacing the compute on a property with type "compute"', function() { | ||
var compute1 = compute(0); | ||
@@ -963,3 +962,3 @@ var compute2 = compute(1); | ||
// TODO remove this condition when taking the plugins out of the main repository | ||
test('value and get (#1521)', function() { | ||
QUnit.test('value and get (#1521)', function() { | ||
var MyMap = CanMap.extend({ | ||
@@ -988,3 +987,3 @@ define: { | ||
test("One event on getters (#1585)", function() { | ||
QUnit.test("One event on getters (#1585)", function() { | ||
@@ -1027,3 +1026,3 @@ var AppState = CanMap.extend({ | ||
test('Can read a defined property with a set/get method (#1648)', function() { | ||
QUnit.test('Can read a defined property with a set/get method (#1648)', function() { | ||
// Problem: "get" is not passed the correct "lastSetVal" | ||
@@ -1055,3 +1054,3 @@ // Problem: Cannot read the value of "foo" | ||
test('Can bind to a defined property with a set/get method (#1648)', 3, function() { | ||
QUnit.test('Can bind to a defined property with a set/get method (#1648)', 3, function() { | ||
// Problem: "get" is not called before and after the "set" | ||
@@ -1089,3 +1088,3 @@ // Problem: Function bound to "foo" is not called | ||
test("type converters handle null and undefined in expected ways (1693)", function() { | ||
QUnit.test("type converters handle null and undefined in expected ways (1693)", function() { | ||
@@ -1159,3 +1158,3 @@ var Typer = CanMap.extend({ | ||
test('Initial value does not call getter', function() { | ||
QUnit.test('Initial value does not call getter', function() { | ||
expect(0); | ||
@@ -1179,3 +1178,3 @@ | ||
test("getters produce change events", function() { | ||
QUnit.test("getters produce change events", function() { | ||
var Map = CanMap.extend({ | ||
@@ -1200,3 +1199,3 @@ define: { | ||
test("Asynchronous virtual properties cause extra recomputes (#1915)", function() { | ||
QUnit.test("Asynchronous virtual properties cause extra recomputes (#1915)", function() { | ||
@@ -1243,3 +1242,3 @@ stop(); | ||
test("double get in a compute (#2230)", function() { | ||
QUnit.test("double get in a compute (#2230)", function() { | ||
var VM = CanMap.extend({ | ||
@@ -1266,3 +1265,3 @@ define: { | ||
test("nullish values are not converted for Type", function(assert) { | ||
QUnit.test("nullish values are not converted for Type", function(assert) { | ||
@@ -1301,3 +1300,3 @@ var VM = CanMap.extend({ | ||
test("Wildcard serialize doesn't apply to getter properties (#4)", function() { | ||
QUnit.test("Wildcard serialize doesn't apply to getter properties (#4)", function() { | ||
var VM = CanMap.extend({ | ||
@@ -1331,3 +1330,3 @@ define: { | ||
test("compute props can be set to null or undefined (#2372)", function(assert) { | ||
QUnit.test("compute props can be set to null or undefined (#2372)", function(assert) { | ||
var VM = CanMap.extend({ define: { | ||
@@ -1343,3 +1342,3 @@ foo: { type: 'compute' } | ||
test("can inherit computes from another map (#2)", 4, function(){ | ||
QUnit.test("can inherit computes from another map (#2)", 4, function(){ | ||
var string1 = 'a string'; | ||
@@ -1389,3 +1388,3 @@ var string2 = 'another string'; | ||
test("can inherit primitive values from another map (#2)", function(){ | ||
QUnit.test("can inherit primitive values from another map (#2)", function(){ | ||
var string1 = 'a'; | ||
@@ -1423,3 +1422,3 @@ var string2 = 'b'; | ||
test("can inherit object values from another map (#2)", function(){ | ||
QUnit.test("can inherit object values from another map (#2)", function(){ | ||
var object1 = {a: 'a'}; | ||
@@ -1465,3 +1464,3 @@ var object2 = {b: 'b'}; | ||
test("can set properties to undefined", function(){ | ||
QUnit.test("can set properties to undefined", function(){ | ||
var MyMap = CanMap.extend({ | ||
@@ -1486,3 +1485,3 @@ define: { | ||
test("subclass defines do not affect superclass ones", function(assert) { | ||
QUnit.test("subclass defines do not affect superclass ones", function(assert) { | ||
var VM = CanMap.extend({ | ||
@@ -1534,3 +1533,3 @@ define: { | ||
test("value function not set on constructor defaults", function(){ | ||
QUnit.test("value function not set on constructor defaults", function(){ | ||
var MyMap = CanMap.extend({ | ||
@@ -1537,0 +1536,0 @@ define: { |
var dev = require('can-util/js/dev/dev'); | ||
var extend = require('can-util/js/assign/assign'); | ||
var isPlainObject = require('can-util/js/is-plain-object/is-plain-object'); | ||
var canEvent = require('can-event'); | ||
var batch = require('can-event/batch/batch'); | ||
var mapEventsMixin = require('can-event-queue/map/map'); | ||
var queues = require('can-queues'); | ||
var mapHelpers = require('can-map/map-helpers'); | ||
@@ -139,6 +139,3 @@ var CanMap = require('can-map'); | ||
if (stub !== false) { | ||
canEvent.trigger(self, 'error', [ | ||
prop, | ||
errors | ||
], true); | ||
mapEventsMixin.dispatch.call(self, 'error', [ prop, errors ], true); | ||
} | ||
@@ -156,3 +153,3 @@ return false; | ||
// do not call update property and return right away | ||
batch.start(); | ||
queues.batch.start(); | ||
var setterCalled = false, | ||
@@ -179,3 +176,3 @@ | ||
batch.stop(); | ||
queues.batch.stop(); | ||
return; | ||
@@ -190,3 +187,3 @@ } | ||
//!steal-remove-end | ||
batch.stop(); | ||
queues.batch.stop(); | ||
return; | ||
@@ -202,3 +199,3 @@ } else { | ||
} | ||
batch.stop(); | ||
queues.batch.stop(); | ||
return this; | ||
@@ -307,7 +304,7 @@ } | ||
if (remove) { | ||
batch.start(); | ||
queues.batch.start(); | ||
res = remove.call(this, current); | ||
if (res === false) { | ||
batch.stop(); | ||
queues.batch.stop(); | ||
return; | ||
@@ -317,3 +314,3 @@ } else { | ||
res = oldRemove.call(this, prop, current); | ||
batch.stop(); | ||
queues.batch.stop(); | ||
return res; | ||
@@ -320,0 +317,0 @@ } |
{ | ||
"name": "can-map-define", | ||
"version": "3.1.2", | ||
"version": "4.0.0", | ||
"description": "Define rich attribute behavior", | ||
@@ -21,3 +21,3 @@ "homepage": "https://canjs.com", | ||
"test": "npm run detect-cycle && npm run jshint && npm run testee", | ||
"jshint": "jshint ./*.js --config", | ||
"jshint": "jshint . --config", | ||
"release:pre": "npm version prerelease && npm publish --tag=pre", | ||
@@ -39,6 +39,7 @@ "release:patch": "npm version patch && npm publish", | ||
"dependencies": { | ||
"can-compute": "^3.1.0", | ||
"can-event": "^3.5.0", | ||
"can-list": "^3.1.0", | ||
"can-map": "^3.1.0", | ||
"can-compute": "^4.0.3", | ||
"can-event-queue": "^1.0.1", | ||
"can-list": "^4.0.0", | ||
"can-map": "^4.0.1", | ||
"can-queues": "^1.0.1", | ||
"can-util": "^3.9.0" | ||
@@ -48,9 +49,7 @@ }, | ||
"bit-docs": "0.0.7", | ||
"can-component": "^3.1.0", | ||
"can-route": "^3.1.0", | ||
"can-stache": "^3.1.0", | ||
"can-component": "^4.0.4", | ||
"can-route": "^4.1.1", | ||
"can-stache": "^4.1.3", | ||
"detect-cyclic-packages": "^1.1.0", | ||
"done-serve": "^0.2.5", | ||
"donejs-cli": "^0.9.5", | ||
"generator-donejs": "^1.0.7", | ||
"done-serve": "^2.0.0", | ||
"jshint": "^2.9.4", | ||
@@ -57,0 +56,0 @@ "steal": "^1.2.9", |
@@ -1,1 +0,1 @@ | ||
import '../can-map-define_test'; | ||
require('../can-map-define_test'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
78998
11
6
1601
+ Addedcan-event-queue@^1.0.1
+ Addedcan-queues@^1.0.1
+ Addedcan-compute@4.1.1(transitive)
+ Addedcan-define-lazy-value@1.1.1(transitive)
+ Addedcan-event-queue@1.1.8(transitive)
+ Addedcan-key@1.2.1(transitive)
+ Addedcan-list@4.2.3(transitive)
+ Addedcan-map@4.3.16(transitive)
+ Addedcan-observation@4.2.0(transitive)
+ Addedcan-observation-recorder@1.3.1(transitive)
+ Addedcan-queues@1.3.2(transitive)
+ Addedcan-reflect-dependencies@1.1.2(transitive)
+ Addedcan-reflect-promise@2.2.1(transitive)
+ Addedcan-simple-observable@2.5.0(transitive)
+ Addedcan-single-reference@1.3.0(transitive)
+ Addedcan-stache-key@1.4.3(transitive)
- Removedcan-event@^3.5.0
- Removedcan-compute@3.3.10(transitive)
- Removedcan-event@3.7.7(transitive)
- Removedcan-list@3.2.2(transitive)
- Removedcan-map@3.6.1(transitive)
- Removedcan-observation@3.3.6(transitive)
- Removedcan-reflect-promise@1.1.5(transitive)
- Removedcan-stache-key@0.1.4(transitive)
Updatedcan-compute@^4.0.3
Updatedcan-list@^4.0.0
Updatedcan-map@^4.0.1