Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bv-ui-core

Package Overview
Dependencies
Maintainers
12
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bv-ui-core - npm Package Compare versions

Comparing version 0.14.0 to 0.14.1

24

lib/getOriginalConstructor/index.js

@@ -10,13 +10,27 @@ /**

var constructors = {};
var constructorNameRegExp = /function\s+([^\(\s]+)/
var iframe;
var getOriginalConstructor = function getOriginalConstructor (constructor) {
if (!constructors[constructor.name]) {
var iframe = document.createElement('iframe');
var constructorName = constructor.name;
// IE11 doesn't have a constructor.name property, so just in case any other
// browsers also don't, use a simple regex to pull the constructor's name
// out of the .toString()'d function declaration, e.g. "function Array()"
if (!constructorName) {
constructorName = constructorNameRegExp.exec(constructor.toString())[1];
}
if (!iframe) {
iframe = document.createElement('iframe');
iframe.src = 'about:blank';
document.head.appendChild(iframe);
constructors[constructor.name] = iframe.contentWindow[constructor.name];
document.head.removeChild(iframe);
} return constructors[constructor.name];
}
if (!constructors[constructorName]) {
constructors[constructorName] = iframe.contentWindow[constructorName];
}
return constructors[constructorName];
};
module.exports = getOriginalConstructor;
{
"name": "bv-ui-core",
"version": "0.14.0",
"version": "0.14.1",
"license": "Apache 2.0",

@@ -5,0 +5,0 @@ "description": "Bazaarvoice UI-related JavaScript",

@@ -34,2 +34,19 @@ /**

it('Should return the definition for constructor.name when constructor.name exists', function () {
var constructor = function Array () {};
Object.defineProperty(constructor, 'name', {
value: 'Array'
})
// We should pull the Array constructor, with prototype, if this is working properly
expect(getOriginalConstructor(constructor)).to.have.property('prototype');
});
it('Should return the definition for the function name where constructor.name doesn\'t exist', function () {
var constructor = function Array () {};
// We should pull the Array constructor, with prototype, if this is working properly
expect(getOriginalConstructor(constructor)).to.have.property('prototype');
});
});
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