Socket
Socket
Sign inDemoInstall

@springernature/global-javascript

Package Overview
Dependencies
Maintainers
11
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@springernature/global-javascript - npm Package Compare versions

Comparing version 2.4.0 to 3.0.0

15

__tests__/unit/dom/get-data-options.spec.js

@@ -7,17 +7,22 @@ import {getDataOptions} from '../../../src/helpers';

OPTION_2: 'data-mycomponent-option2',
OPTION_3: 'data-mycomponent-option3'
OPTION_3: 'data-mycomponent-option3',
OPTION_4: 'data-mycomponent-option4',
OPTION_5: 'data-mycomponent-option5'
};
const element = {};
beforeEach(() => {
document.body.innerHTML = `
<div data-mycomponent-option1="foo" data-mycomponent-option2="bar" data-mycomponent-option3="baz" data-notmycomponent="test">My Component</div>
<div data-mycomponent-option1="foo" data-mycomponent-option2="bar" data-mycomponent-option3="baz" data-mycomponent-option4="true" data-mycomponent-option5="false" data-notmycomponent="test">My Component</div>
`;
element.COMPONENT = document.querySelector('div');
});
test('Should return an Object with the values for each key as the values of the data-attributes', () => {
const component = document.querySelector('div');
const options = getDataOptions(component, DataOptions);
const options = getDataOptions(element.COMPONENT, DataOptions);
expect(options).toMatchObject({OPTION_1: 'foo', OPTION_2: 'bar', OPTION_3: 'baz'});
expect(options).toMatchObject({OPTION_1: 'foo', OPTION_2: 'bar', OPTION_3: 'baz', OPTION_4: true, OPTION_5: false});
});
});
# History
## 3.0.0 (2020-11-13)
* BREAKING: Convert "true" and "false" attributes to boolean
## 2.4.0 (2020-08-24)

@@ -4,0 +7,0 @@ * FEATURE: setCookie util

{
"name": "@springernature/global-javascript",
"version": "2.4.0",
"version": "3.0.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "Globally shared Javascript helpers",

@@ -16,3 +16,5 @@ /**

if (attributeValue) {
dataOptions[key] = attributeValue;
// 'true' and 'false' attribute values need to be converted to a boolean
// Checking equality against 'true' will return a boolean of true or false. e.g. 'false' === 'true' returns false
dataOptions[key] = (attributeValue === 'true' || attributeValue === 'false') ? attributeValue === 'true' : attributeValue;
}

@@ -19,0 +21,0 @@ }

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