Skip to content

Commit 6c00fea

Browse files
authored
♻️ refactor: improve logic (#622)
* ♻️ refactor: improve logic * deps: use `@rc-component/np` replace `np` * chore: fix script
1 parent c1c0e57 commit 6c00fea

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"coverage": "npm test -- --coverage",
2828
"lint": "eslint src/ --ext .tsx,.ts & eslint tests/ --ext .tsx,.ts",
2929
"prepare": "husky install",
30-
"prepublishOnly": "npm run compile && np --yolo --no-publish",
30+
"prepublishOnly": "npm run compile && rc-np",
3131
"start": "dumi dev",
3232
"test": "rc-test"
3333
},
@@ -42,6 +42,7 @@
4242
},
4343
"devDependencies": {
4444
"@rc-component/father-plugin": "^2.0.1",
45+
"@rc-component/np": "^1.0.3",
4546
"@testing-library/react": "^16.0.0",
4647
"@types/jest": "^29.4.0",
4748
"@types/node": "^22.5.5",
@@ -60,7 +61,6 @@
6061
"glob": "^9.2.1",
6162
"husky": "^9.1.6",
6263
"lint-staged": "^15.1.0",
63-
"np": "^10.0.2",
6464
"prettier": "^3.3.2",
6565
"rc-test": "^7.0.14",
6666
"react": "^18.0.0",

src/Dom/dynamicCSS.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ export function injectCSS(css: string, option: Options = {}) {
121121
}
122122

123123
function findExistNode(key: string, option: Options = {}) {
124-
const container = getContainer(option);
124+
let { styles } = option;
125+
126+
styles ||= findStyles(getContainer(option));
125127

126-
return (option.styles || findStyles(container)).find(
127-
node => node.getAttribute(getMark(option)) === key,
128-
);
128+
return styles.find(node => node.getAttribute(getMark(option)) === key);
129129
}
130130

131131
export function removeCSS(key: string, option: Options = {}) {

0 commit comments

Comments
 (0)