Skip to content

Commit

Permalink
refactor: Use attr for setting order
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Sep 5, 2022
1 parent d723136 commit 7444714
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Dom/dynamicCSS.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import canUseDom from './canUseDom';

const APPEND_ORDER = '_rc_util_order';
const APPEND_ORDER = 'data-rc-order';
const MARK_KEY = `rc-util-key`;

const containerCache = new Map<Element, Node & ParentNode>();
Expand Down Expand Up @@ -46,7 +46,7 @@ function findStyles(container: Element) {
return Array.from(
(containerCache.get(container) || container).children,
).filter(
node => node.tagName === 'STYLE' && node[APPEND_ORDER],
node => node.tagName === 'STYLE' && node.hasAttribute(APPEND_ORDER),
) as HTMLStyleElement[];
}

Expand All @@ -58,7 +58,7 @@ export function injectCSS(css: string, option: Options = {}) {
const { csp, prepend } = option;

const styleNode = document.createElement('style');
styleNode[APPEND_ORDER] = getOrder(prepend);
styleNode.setAttribute(APPEND_ORDER, getOrder(prepend));

if (csp?.nonce) {
styleNode.nonce = csp?.nonce;
Expand All @@ -72,7 +72,7 @@ export function injectCSS(css: string, option: Options = {}) {
// If is queue `prepend`, it will prepend first style and then append rest style
if (prepend === 'queue') {
const existStyle = findStyles(container).filter(node =>
['prepend', 'prependQueue'].includes(node[APPEND_ORDER]),
['prepend', 'prependQueue'].includes(node.getAttribute(APPEND_ORDER)),
);
if (existStyle.length) {
container.insertBefore(
Expand Down

1 comment on commit 7444714

@vercel
Copy link

@vercel vercel bot commented on 7444714 Sep 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

util – ./

util-git-master-react-component.vercel.app
util-react-component.vercel.app
util.vercel.app

Please sign in to comment.