Skip to content
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

Enable manual polyfill #256

Merged
merged 29 commits into from
Oct 14, 2024
Merged
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c2a3f25
allow polyfilling a single style element
marchbox Oct 8, 2024
8eeb7a8
remove unnecessary import
marchbox Oct 8, 2024
fe5389c
make polyfill options more flexible and allow a list of target elements
marchbox Oct 9, 2024
a58268f
simplify element list type
marchbox Oct 9, 2024
c0ceb70
add demo for imperative polyfill
marchbox Oct 9, 2024
dc5e6d4
remove unnecessary variable
marchbox Oct 9, 2024
96f825a
remove unnecessary variable
marchbox Oct 9, 2024
24df34b
remove unnecessary promise
marchbox Oct 9, 2024
0cfd3a4
fix edge
marchbox Oct 9, 2024
3b63415
add tests for fetch
marchbox Oct 9, 2024
52bc1a6
add e2e tests
marchbox Oct 9, 2024
7be5e54
add comment to clarify backward compatibility concern
marchbox Oct 10, 2024
c97ae3e
fix linting issues
marchbox Oct 10, 2024
bbadbae
use array filter for better readability
marchbox Oct 10, 2024
4f75075
centralize elements option type check
marchbox Oct 10, 2024
73259da
rename imperative to manual
marchbox Oct 10, 2024
d00ab88
load css dynamically for manual polyfill demo in supported browsers
marchbox Oct 10, 2024
912c553
add test coverage for polyfilling multiple sets of elements
marchbox Oct 11, 2024
798561f
support automatic inline style polyfill with manual polyfill
marchbox Oct 11, 2024
e921c41
fix linting issues
marchbox Oct 11, 2024
e5befac
attempt to deflake test
marchbox Oct 11, 2024
167b030
change includeInlineStyles option to excludeInlineStyles
marchbox Oct 11, 2024
ef0b87d
update based on feedback
marchbox Oct 12, 2024
202d17b
fix linting issues
marchbox Oct 12, 2024
00e1a44
support global options
marchbox Oct 12, 2024
9919720
fix linting issues
marchbox Oct 12, 2024
1628931
simplify code for better readability
marchbox Oct 14, 2024
63c1bcb
Merge branch 'oddbird:main' into add-to-polyfill
marchbox Oct 14, 2024
b4915fa
fix unit tests
marchbox Oct 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,14 @@ async function position(rules: AnchorPositions, useAnimationFrame = false) {
}
}

export async function polyfill(animationFrame?: boolean) {
export async function polyfill(animationFrame?: boolean, el?: HTMLStyleElement) {
marchbox marked this conversation as resolved.
Show resolved Hide resolved
const useAnimationFrame =
animationFrame === undefined
? Boolean(window.UPDATE_ANCHOR_ON_ANIMATION_FRAME)
: animationFrame;

// fetch CSS from stylesheet and inline style
let styleData = await fetchCSS();
let styleData = el ? [{el, css: el.textContent ?? ''}] : await fetchCSS();
marchbox marked this conversation as resolved.
Show resolved Hide resolved

// pre parse CSS styles that we need to cascade
const cascadeCausedChanges = await cascadeCSS(styleData);
Expand Down
Loading