@putout/bundle 4.6.9 → 4.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/putout.js +35 -9
- package/bundle/putout.min.js +1 -1
- package/package.json +1 -1
package/bundle/putout.js
CHANGED
|
@@ -69974,6 +69974,9 @@ jsx.getAttributeNode = getAttributeNode;
|
|
|
69974
69974
|
function getAttributeNode(path, name) {
|
|
69975
69975
|
let result = null;
|
|
69976
69976
|
|
|
69977
|
+
if (!path)
|
|
69978
|
+
return result;
|
|
69979
|
+
|
|
69977
69980
|
const node = path.node || path;
|
|
69978
69981
|
const {attributes} = node.openingElement;
|
|
69979
69982
|
|
|
@@ -69987,25 +69990,26 @@ function getAttributeNode(path, name) {
|
|
|
69987
69990
|
return result;
|
|
69988
69991
|
}
|
|
69989
69992
|
|
|
69990
|
-
jsx.getAttributeValue =
|
|
69993
|
+
jsx.getAttributeValue = getAttributeValue;
|
|
69994
|
+
function getAttributeValue(path, attributeName) {
|
|
69991
69995
|
const attribute = getAttributeNode(path, attributeName);
|
|
69992
69996
|
|
|
69993
69997
|
if (!attribute)
|
|
69994
69998
|
return '';
|
|
69995
69999
|
|
|
69996
70000
|
return attribute.value.value;
|
|
69997
|
-
}
|
|
69998
|
-
|
|
69999
|
-
|
|
70001
|
+
}
|
|
70002
|
+
jsx.addAttributeValue = addAttributeValue;
|
|
70003
|
+
function addAttributeValue(path, name, value) {
|
|
70000
70004
|
const attributeNode = getAttributeNode(path, name);
|
|
70001
70005
|
|
|
70002
70006
|
if (attributeNode.value.value.includes(value))
|
|
70003
70007
|
return;
|
|
70004
70008
|
|
|
70005
70009
|
setLiteralValue(attributeNode.value, `${attributeNode.value.value} ${value}`);
|
|
70006
|
-
}
|
|
70007
|
-
|
|
70008
|
-
|
|
70010
|
+
}
|
|
70011
|
+
jsx.removeAttributeValue = removeAttributeValue;
|
|
70012
|
+
function removeAttributeValue(path, name, attributeValue) {
|
|
70009
70013
|
if (!path)
|
|
70010
70014
|
return;
|
|
70011
70015
|
|
|
@@ -70016,8 +70020,7 @@ jsx.removeAttributeValue = (path, name, attributeValue) => {
|
|
|
70016
70020
|
|
|
70017
70021
|
if (value.includes(attributeValue))
|
|
70018
70022
|
setLiteralValue(classAttribute.value, value.replace(RegExp(`\\s?${attributeValue}`), ''));
|
|
70019
|
-
}
|
|
70020
|
-
|
|
70023
|
+
}
|
|
70021
70024
|
jsx.setAttributeValue = (node, name, value) => {
|
|
70022
70025
|
const attributeNode = getAttributeNode(node, name);
|
|
70023
70026
|
|
|
@@ -70025,6 +70028,29 @@ jsx.setAttributeValue = (node, name, value) => {
|
|
|
70025
70028
|
setLiteralValue(attributeNode.value, value);
|
|
70026
70029
|
};
|
|
70027
70030
|
|
|
70031
|
+
jsx.addClassName = (path, name) => {
|
|
70032
|
+
addAttributeValue(path, 'className', name);
|
|
70033
|
+
};
|
|
70034
|
+
|
|
70035
|
+
jsx.getClassName = getClassName;
|
|
70036
|
+
function getClassName(path) {
|
|
70037
|
+
return getAttributeValue(path, 'className');
|
|
70038
|
+
}
|
|
70039
|
+
|
|
70040
|
+
jsx.removeClassName = (path, name) => {
|
|
70041
|
+
removeAttributeValue(path, 'className', name);
|
|
70042
|
+
};
|
|
70043
|
+
|
|
70044
|
+
jsx.containsClassName = (path, className) => {
|
|
70045
|
+
const classNameValue = getClassName(path);
|
|
70046
|
+
return classNameValue.includes(className);
|
|
70047
|
+
};
|
|
70048
|
+
|
|
70049
|
+
jsx.hasDataName = (path, value = '') => {
|
|
70050
|
+
const attribute = getAttributeValue(path, 'data-name');
|
|
70051
|
+
return attribute === value;
|
|
70052
|
+
};
|
|
70053
|
+
|
|
70028
70054
|
/**
|
|
70029
70055
|
* The MIT License (MIT)
|
|
70030
70056
|
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|