New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

can-construct-super

Package Overview
Dependencies
Maintainers
7
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-construct-super - npm Package Compare versions

Comparing version 3.0.3 to 3.1.0-pre.0

34

can-construct-super.js
/* global require, module */
var can = require('can-util');
var Construct = require('can-construct');
var hasOwnProperty = Object.prototype.hasOwnProperty;
// tests if we can get super in .toString()

@@ -12,11 +13,30 @@ var isFunction = can.isFunction,

return function () {
var tmp = this._super,
ret;
// Add a new ._super() method that is the same method
// but on the super-class
this._super = base[name];
var hasExistingValue = false;
var existingValue;
var prototype = getPrototypeOf(this);
var existingPrototypeValue = prototype._super;
/* We must delete the instance's _super so the lookup
will reach the prototype. */
if (hasOwnProperty.call(this, '_super')) {
hasExistingValue = true;
existingValue = this._super;
/* NOTE: if the object is sealed this will not work.
The '_super' key cannot be used on the instance
in that rare case. */
delete this._super;
}
/* Add a new ._super() method that is the same method
but on the super-class. It must be set on the prototype
because the instance may be sealed. */
prototype._super = base[name];
// The method only need to be bound temporarily, so we
// remove it when we're done executing
ret = fn.apply(this, arguments);
this._super = tmp;
var ret = fn.apply(this, arguments);
prototype._super = existingPrototypeValue;
if (hasExistingValue) {
this._super = existingValue;
}
return ret;

@@ -23,0 +43,0 @@ };

{
"name": "can-construct-super",
"version": "3.0.3",
"version": "3.1.0-pre.0",
"description": "Provides a reference to the prototypal parent using this._super in can-construct objects",

@@ -9,7 +9,7 @@ "main": "can-construct-super",

"version": "git commit -am \"Update dist for release\" && git checkout -b release && git add -f dist/",
"postversion": "git push --tags && git checkout master && git branch -D release && git push",
"postversion": "git push --tags && git checkout can-reflect && git branch -D release && git push",
"testee": "testee test/test.html --browsers firefox",
"test": "npm run jshint && npm run testee",
"jshint": "jshint ./*.js --config",
"release:pre": "npm version prerelease && npm publish",
"release:pre": "npm version prerelease && npm publish --tag=pre",
"release:patch": "npm version patch && npm publish",

@@ -37,4 +37,4 @@ "release:minor": "npm version minor && npm publish",

"dependencies": {
"can-construct": "^3.0.0",
"can-util": "^3.0.0"
"can-construct": "^3.2.0-pre.0",
"can-util": "^3.9.0-pre.4"
},

@@ -41,0 +41,0 @@ "devDependencies": {

@@ -127,1 +127,25 @@ /* global require, test, stop, start, expect, equal, Promise */

});
QUnit.test("_super should work for sealed instances", function () {
var A = Construct.extend({
init: function (arg) {
this.arg = arg + 1;
},
add: function (num) {
return this.arg + num;
}
});
var B = A({
init: function (arg) {
this._super(arg + 2);
},
add: function (arg) {
console.log(this)
return this._super(arg + 1);
}
});
var b = new B(1);
Object.seal(b);
equal(b.arg, 4, 'should instantiate properly');
equal(b.add(2), 7, 'should call methods properly');
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc