dom-component-parser
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -16,10 +16,10 @@ 'use strict'; | ||
var options = function options(component) { | ||
var options = function options(node) { | ||
var parseOption = function parseOption(option) { | ||
if (!component.hasAttribute('data-' + (0, _helpers.toSnakeCase)(option))) { | ||
if (!node.hasAttribute('data-' + (0, _helpers.toSnakeCase)(option))) { | ||
if (defaultOptions[option] === 'required') { | ||
throw new Error('Option `' + option + '` is required on component `' + component + '`'); | ||
throw new Error('Option `' + option + '` is required on component `' + tag + '`'); | ||
} | ||
@@ -30,3 +30,3 @@ | ||
var value = component.getAttribute('data-' + (0, _helpers.toSnakeCase)(option)); | ||
var value = node.getAttribute('data-' + (0, _helpers.toSnakeCase)(option)); | ||
@@ -49,3 +49,3 @@ if (value === '') { | ||
node: node, | ||
options: options(component) | ||
options: options(node) | ||
}; | ||
@@ -52,0 +52,0 @@ }); |
{ | ||
"name": "dom-component-parser", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Extract nodes and corresponding custom options from the DOM", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -5,10 +5,10 @@ import { keys, toSnakeCase } from './helpers'; | ||
const options = component => { | ||
const options = node => { | ||
const parseOption = option => { | ||
if (!component.hasAttribute(`data-${toSnakeCase(option)}`)) { | ||
if (!node.hasAttribute(`data-${toSnakeCase(option)}`)) { | ||
if (defaultOptions[option] === 'required') { | ||
throw new Error(`Option \`${option}\` is required on component \`${component}\``); | ||
throw new Error(`Option \`${option}\` is required on component \`${tag}\``); | ||
} | ||
@@ -19,3 +19,3 @@ | ||
const value = component.getAttribute(`data-${toSnakeCase(option)}`); | ||
const value = node.getAttribute(`data-${toSnakeCase(option)}`); | ||
@@ -37,3 +37,3 @@ if (value === '') { | ||
node, | ||
options: options(component), | ||
options: options(node), | ||
})); | ||
@@ -40,0 +40,0 @@ }; |
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
15336