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

Request: opt-in mechanism for stylesheets #245

Closed
tuespetre opened this issue Sep 13, 2024 · 1 comment · Fixed by #256
Closed

Request: opt-in mechanism for stylesheets #245

tuespetre opened this issue Sep 13, 2024 · 1 comment · Fixed by #256
Labels
enhancement New feature or request

Comments

@tuespetre
Copy link
Contributor

I've got stylesheets that I do not want the polyfill to process. For instance, my project's main stylesheet, and an auxiliary stylesheet with a media attribute for conditional loading. These each have a couple of odd and end rules in it that have properties like inset: auto; or top: 0;, so the polyfill is processing them and generating custom properties for them, even though I know for a fact that these rules will never be relevant to anything I am using anchor positioning with. I want to avoid the re-rendering caused by this, but I would rather not sequester those odd couple of rules into separate stylesheets, they are rather happy just where they are 😄

What I would like to see is a configuration option that puts the polyfill into "opt-in mode", by allowing me to specify an attribute name so that only stylesheets with that attribute name will be processed.

// Still accept the single boolean argument for compatibility:
polyfill(true);

// Also accept an object argument...
polyfill({ 
    updateAnchorOnAnimationFrame: true
});

// ... and add the new option to the object argument for "opt-in mode".
polyfill({
    optInAttribute: 'data-polyfill-anchor'
}); 

// Also allow a global variable to specify the object argument.
window.ANCHOR_POSITIONING_POLYFILL_OPTIONS = {
    updateAnchorOnAnimationFrame: true,
    optInAttribute: 'data-polyfill-anchor'
};

Let me know what y'all think

@tuespetre tuespetre added the enhancement New feature or request label Sep 13, 2024
@jgerigmeyer jgerigmeyer linked a pull request Oct 11, 2024 that will close this issue
@jgerigmeyer
Copy link
Member

This is released in v0.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants