can-stache-key
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -275,4 +275,3 @@ var observeReader = require("can-stache-key"); | ||
observeReader.read(data, reads, { | ||
callMethodsOnObservables: true, | ||
warnOnFunctionCall: "A Warning" | ||
callMethodsOnObservables: true | ||
}); | ||
@@ -282,1 +281,17 @@ | ||
}); | ||
testHelpers.dev.devOnlyTest("a warning is not displayed when functions are read but not called due to proxyMethods=false (#15)", function() { | ||
var teardown = testHelpers.dev.willWarn(/"func" is being called as a function/); | ||
var func = function() { | ||
QUnit.ok(false, "method not called"); | ||
}; | ||
var data = new SimpleMap({ func: func }); | ||
var reads = observeReader.reads("func"); | ||
observeReader.read(data, reads, { | ||
isArgument: true, | ||
proxyMethods: false | ||
}); | ||
QUnit.equal(teardown(), 0, "warning not displayed"); | ||
}); |
@@ -153,18 +153,37 @@ var Observation = require('can-observation'); | ||
//!steal-remove-start | ||
dev.warn( | ||
(options.filename ? options.filename + ':' : '') + | ||
(options.lineNumber ? options.lineNumber + ': ' : '') + | ||
'"' + reads[0].key + '" is being called as a function.\n' + | ||
'\tThis will not happen automatically in an upcoming release.\n' + | ||
'\tYou should call it explicitly using "' + reads[0].key + '()".\n\n' | ||
); | ||
var showWarning = function() { | ||
dev.warn( | ||
(options.filename ? options.filename + ':' : '') + | ||
(options.lineNumber ? options.lineNumber + ': ' : '') + | ||
'"' + reads[0].key + '" is being called as a function.\n' + | ||
'\tThis will not happen automatically in an upcoming release.\n' + | ||
'\tYou should call it explicitly using "' + reads[0].key + '()".\n\n' | ||
); | ||
}; | ||
//!steal-remove-end | ||
if(options.callMethodsOnObservables && canReflect.isObservableLike(prev) && canReflect.isMapLike(prev)) { | ||
//!steal-remove-start | ||
showWarning(); | ||
//!steal-remove-end | ||
return value.apply(prev, options.args || []); | ||
} | ||
else if ( options.isArgument && i === reads.length ) { | ||
return options.proxyMethods !== false ? value.bind(prev) : value; | ||
if (options.proxyMethods === false) { | ||
return value; | ||
} | ||
//!steal-remove-start | ||
showWarning(); | ||
//!steal-remove-end | ||
return value.bind(prev); | ||
} | ||
//!steal-remove-start | ||
showWarning(); | ||
//!steal-remove-end | ||
return value.apply(prev, options.args || []); | ||
@@ -171,0 +190,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/*can-stache-key@0.1.1#can-stache-key*/ | ||
/*can-stache-key@0.1.2#can-stache-key*/ | ||
define([ | ||
@@ -119,3 +119,6 @@ 'require', | ||
} else if (options.isArgument && i === reads.length) { | ||
return options.proxyMethods !== false ? value.bind(prev) : value; | ||
if (options.proxyMethods === false) { | ||
return value; | ||
} | ||
return value.bind(prev); | ||
} | ||
@@ -122,0 +125,0 @@ return value.apply(prev, options.args || []); |
@@ -1,2 +0,2 @@ | ||
/*can-stache-key@0.1.1#can-stache-key*/ | ||
/*can-stache-key@0.1.2#can-stache-key*/ | ||
var Observation = require('can-observation'); | ||
@@ -107,3 +107,6 @@ var dev = require('can-log/dev/dev'); | ||
} else if (options.isArgument && i === reads.length) { | ||
return options.proxyMethods !== false ? value.bind(prev) : value; | ||
if (options.proxyMethods === false) { | ||
return value; | ||
} | ||
return value.bind(prev); | ||
} | ||
@@ -110,0 +113,0 @@ return value.apply(prev, options.args || []); |
@@ -130,3 +130,3 @@ /*[global-shim-start]*/ | ||
/*can-stache-key@0.1.1#can-stache-key*/ | ||
/*can-stache-key@0.1.2#can-stache-key*/ | ||
define('can-stache-key', [ | ||
@@ -249,3 +249,6 @@ 'require', | ||
} else if (options.isArgument && i === reads.length) { | ||
return options.proxyMethods !== false ? value.bind(prev) : value; | ||
if (options.proxyMethods === false) { | ||
return value; | ||
} | ||
return value.bind(prev); | ||
} | ||
@@ -252,0 +255,0 @@ return value.apply(prev, options.args || []); |
{ | ||
"name": "can-stache-key", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Read and write keys on a value", | ||
@@ -5,0 +5,0 @@ "homepage": "https://canjs.com", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61084
1484