-
Notifications
You must be signed in to change notification settings - Fork 191
feat: Queue support #337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: Queue support #337
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
11e94fb
feat: dynamic css support prepend queue
zombieJ 1a51043
test: add test case
zombieJ 9ac34d6
test: includes prepend
zombieJ 34a5902
refactor: replace prepend with insertBefore
zombieJ 5431b9d
chore: force CI
zombieJ 6217978
chore: lock version
zombieJ 426c99d
chore: Trigger CI again
zombieJ deb11e6
chore: try exclude
zombieJ 28f76b5
chore: more
zombieJ 7ad88c5
chore: try ignore
zombieJ b8bc2aa
chore: typing
zombieJ ea0da94
chore: sad
zombieJ 804af2e
chore: update
zombieJ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
import { updateCSS, removeCSS } from '../src/Dom/dynamicCSS'; | ||
import type { Prepend } from '../src/Dom/dynamicCSS'; | ||
|
||
function injectStyle(id: number, prepend?: Prepend) { | ||
const randomColor = Math.floor(Math.random() * 16777215).toString(16); | ||
|
||
updateCSS(`body { background: #${randomColor} }`, `style-${id}`, { | ||
prepend, | ||
}); | ||
} | ||
|
||
export default () => { | ||
const [id, setId] = React.useState(0); | ||
const idRef = React.useRef(id); | ||
idRef.current = id; | ||
|
||
// Clean up | ||
React.useEffect(() => { | ||
return () => { | ||
for (let i = 0; i <= idRef.current; i += 1) { | ||
removeCSS(`style-${i}`); | ||
} | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<button | ||
onClick={() => { | ||
injectStyle(id, 'queue'); | ||
setId(id + 1); | ||
}} | ||
> | ||
Prepend Queue: {id} | ||
</button> | ||
|
||
<button | ||
onClick={() => { | ||
injectStyle(-1); | ||
}} | ||
> | ||
Append | ||
</button> | ||
</> | ||
); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所以这里第一个 style 还是 prepend?qiankun 没劫持 prepend,会透出去,后面 exitStyle 找不到还是会继续 prepend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prepend 让 qiankun 处理就好了,否则 rc-util 就要做框架检测了,这样就变成针对 qiankun 的耦合了。