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

@artisfy/outputjs

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@artisfy/outputjs - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

9

index.js

@@ -5,3 +5,7 @@ import {

} from "./dataObjFromElems";
import { setLocationKeyValue, getLocationKeyValue } from "./parseNode";
import {
setLocationKeyValue,
getLocationKeyValue,
setValueForKeyName
} from "./parseNode";

@@ -70,5 +74,6 @@ // special properties:

setLocationKeyValue,
getLocationKeyValue
getLocationKeyValue,
setValueForKeyName
}
{
"name": "@artisfy/outputjs",
"version": "1.0.2",
"version": "1.0.3",
"description": "Recursively crawls the DOM and gathers data from custom attributes",

@@ -5,0 +5,0 @@ "main": "index.js",

import { forEachAttr } from '@artisfy/hummingbird/lib/dom';
import { dashToCamelCase } from '@artisfy/hummingbird/lib/string';
import { dashToCamelCase, camelCaseToDash } from '@artisfy/hummingbird/lib/string';
import { formatSpaces } from "@artisfy/parse-data-attributes";

@@ -51,3 +51,3 @@

locationString = formatSpaces(locationString);
let [selector, elemAttribute] = locationString.split(" "); // e.g. ["."]
let [selector, elemAttribute] = locationString.split(" "); // e.g. [".selector", "attr:data-x-text"]
let targetElem;

@@ -79,2 +79,4 @@

// use like this: setLocationKeyValue(elem, ".selector", "example text")
// ^ this will default to setting innerText if there's no 2nd argument
function setLocationKeyValue (elem, locationString, value) {

@@ -96,2 +98,20 @@ let {elemAttribute, targetElem} = getDataFromLocationString(elem, locationString);

// utility function for setting a value on a data attribute
// using a key name that could be EITHER a location key or an output key
function setValueForKeyName (elem, keyName, value) {
// convert the key name to output and location format
let dashCaseKeyName = camelCaseToDash(keyName)
let outputAttrFormat = "data-o-key-" + dashCaseKeyName;
let locationAttrFormat = "data-l-key-" + dashCaseKeyName;
// if the output format is found, set the value of that attribute
if (elem.hasAttribute(outputAttrFormat)) {
elem.setAttribute(outputAttrFormat, value);
}
// if the location format is found, set the value using `setLocationKeyValue`
if (elem.hasAttribute(locationAttrFormat)) {
let locationString = elem.getAttribute(locationAttrFormat);
setLocationKeyValue(elem, locationString, value);
}
}
export {

@@ -101,3 +121,4 @@ parseNode,

getLocationKeyValue,
setLocationKeyValue
setLocationKeyValue,
setValueForKeyName
};

@@ -104,0 +125,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