Skip to content

Remove <style scoped> #552

Closed
Closed

Description

@domenic

<style scoped> has not been getting implementer interest. Would Firefox be OK with removing it? @smaug----, thoughts?

It seems shadow DOM and stylesheets restricted to a shadow tree ends up solving more of the real-world problems developers are faced with, although the two features don't work the same and it's certainly possible to conceive of use cases better served by style scoped.

I think that if nothing else, we should set a deadline for removal, similar to MediaController.

Related bugs that could be resolved upon removal:

Activity

  1. added
    removal/deprecation
    on Jan 24, 2016
  2. smaug---- commented on Jan 24, 2016

    @smaug----

    I'm not the best person to answer to this, but I've heard several times how web devs seem to like the <style scope>, and were just annoyed that it is not implemented everywhere.

  3. annevk commented on Feb 1, 2016

    @annevk
    Member
  4. smaug---- commented on Feb 1, 2016

    @smaug----

    Perhaps @heycam or @dbaron.

    (I don't know how https://www.w3.org/Bugs/Public/show_bug.cgi?id=27303#c36 explains why devs wouldn't want this. That seems to be about different case mostly. Not about scoped handling per se. And even the case where tertiary loads before secondary can be a very valid case - say in a view where each section are in the same row of a table and the size of cells is defined in some global style.)

    Forcing people to use shadow DOM to achieve certain styling characteristic feels overkill.

    But in general, I don't have strong feelings about styling related issues, at least partially because I don't know all the history behind various design decisions.

  5. prlbr commented on Feb 2, 2016

    @prlbr

    As a developer I would appreciate scoped styles a lot. They would be a very welcome tool to me.

    But I also think that it doesn't make sense to have features in the specification that most browser vendors don't intend to implement. Knowing their reasons for not including it would be interesting though.

  6. added 3 commits that reference this issue on May 10, 2016
    5f55baa
    5993b94
    47154b5
  7. added a commit that references this issue on May 11, 2016
    c2a3b2a
  8. dbaron commented on May 11, 2016

    @dbaron
    Member

    Is there an explanation for why this doesn't address the demand that it was created for? It's not clear to me why this was removed.

  9. domenic commented on May 11, 2016

    @domenic
    MemberAuthor

    This isn't really an issue of there something being wrong with the feature. Rather, it's a feature with only one implementation, and no positive signals from any other vendors. As such, it's not part of the interoperable web platform, and not on track to become such, so it needs to be removed. It is similar to MediaController, the microdata API, and requestAutocomplete in that regard.

    (requestAutocomplete had positive signals from Gecko I guess, but Chrome removed it, leaving Gecko as the only positive signal.)

    Some other more general discussions at #209.

    Its use cases also overlap with shadow DOM, although they are certainly different. (E.g., styles from outside are limited in how they can impact the shadow DOM, whereas outside styles can always reach inside an <article><style scoped>...</style>...</article>. Shadow DOM prevents both inward and outward leakage, whereas style scoped only prevents outward leakage.)

  10. wturnerharris commented on Jun 21, 2016

    @wturnerharris

    This is a shame. Retaining <style scoped> could be considered beneficial since I see <style> tags used within the <body> quite frequently. I believe it was always restricted to being in <head> only, so the introduction of the scoped attribute simply allowed these to be mixed within the DOM for presentational purposes. I see this quite frequently when attempting to serve device-specific sizes as background images. While this works with the image-set notation, the feature is only supported by webkit/blink engines, so Firefox/Gecko and Edge/IE are left in the cold.

  11. igabesz commented on Jun 21, 2016

    @igabesz

    Note that the necessity of this feature is further decreased by nesting available in SASS and LESS. It's not the same but it covers the common use-cases:

    .div-that-would-containt-scoped-styles {
      /* quasi-nested styles */
      .some-div { color: red; }
    }

    Which is compiled to the following CSS:

    .div-that-would-containt-scoped-styles .some-div { color: red; }

    As a dev I was also looking forward for this feature, too bad it seems we won't get it.

  12. 36 remaining items

  13. DanMan commented on Apr 29, 2017

    @DanMan

    This would have been really useful on sites where users can customize a website through CSS themselves, because the scope could have prevented them from screwing up things they shouldn't have customized in the 1st place. Example: styling of sub-reddits.

    But I guess this could be achieved by prefixing every CSS rule with an additional selector by a pre-processor.

  14. nektro commented on May 25, 2017

    @nektro
    Member

    I see a lot of the comments on this bringing up that 1) only one browser supports the feature, and 2) custom elements solves a lot of the same problem with shadow dom, etc. I would definitely use scoped styles and its sad to see this feature dropped.

    With that said, is there any word on when v1 of CE or SD will be supported in more than just chrome?

  15. workguy66 commented on May 25, 2017

    @workguy66
  16. ianthedev commented on May 25, 2017

    @ianthedev

    In my humble opinion, this "scoped style" is not a good idea because it requires user to add the tags into specific locations in HTML code and requires users to remove the tags from HTML code when they no longer need those styles.

    CSS approaches should not require users to modify HTML code too often like that.

  17. inoas commented on May 25, 2017

    @inoas

    Shadow dom is much too complicated.

    A declarative html/css only approach that stops leaks TO the surrounding context and optionally stops leaking FROM the surrounding context is what IMHO the whole web community is waiting for years now.

  18. nektro commented on May 25, 2017

    @nektro
    Member

    Being able to scope a <style> to only affecting its neighbors and their children, is not only great for debugging a whole block of code, but it would also make inlined <style>s a lot more viable.

  19. heycam commented on Jun 20, 2017

    @heycam
    Contributor
  20. shellbryson commented on Jul 14, 2017

    @shellbryson

    A shame. I just finished FE development of a componentized site delivered via Drupal. Most of the images were CSS defined. Being able to <style> per component was essential in giving the content owners the flexibility to upload images for breakpoints and colors. We scoped the styles using component IDs, which avoided the issue of style-bleeding described by others. It'd be "nice" if the project validated too.

  21. btopro commented on Nov 9, 2017

    @btopro

    A polyfill I found if anyone needs this capability back in the platform https://github.com/thomaspark/scoper

    A few years down the road and the quote from above "Forcing people to use shadow DOM to achieve certain styling characteristic feels overkill." is ringing true for me right now when this would have fixed an issue immediately :)

  22. inoas commented on Nov 9, 2017

    @inoas

    Shadow DOM would be okay if there was a declarative way to do so without Javascript being a requirement to render scoped CSS.

  23. ilovecomputers commented on Feb 9, 2018

    @ilovecomputers

    I too want to voice my disapproval for removing scoped style tags from the spec.

    Even with the shadow DOM, while we prevented styles from leaking out, we also prevented user styles from cascading in. There's been proposals to style inside the shadow DOM, but it leaves the discretion of what can be styled to the element author.

    <style scoped> was the only web spec that allowed authors to prevent their components from leaking out styles onto the user, but still allow the user to style a custom component within their page.

    As an aside, one form of styles do pierce the shadow DOM and that is inherited styles (color, font, etc.) unless the component author adds a :host { all:initial; }. That is even more hostile to the user; bringing in a custom element that's in an illegible font that cannot be changed. With <style scoped> that font could be changed and that custom element won't change the font on matching selectors outside of itself.

  24. zlamma commented on Feb 9, 2018

    @zlamma

    That is even more hostile to the user

    @ilovecomputers - I concur. I would even add that it's against the open, inclusive, sharing-friendly spirit of all other WWW standards that brought us the web we have today.

    Consider:

    • JavaScript - interpreted (so source is available), malleable, runtime patchable, extendable without asking for agreement of the author🤗
    • HTML - intelligible, easy to understand, open data format, which allows to take any existent text/page and publish a improvement/mashup/extension without asking for agreement of the author🤗
    • URI - allows to link to any information, including proprietary, without asking for agreement of the author🤗
    • RDF - allows to create open databases where everyone can make statements about any information, even in proprietary databases without asking for agreement of the author🤗
    • CSS - styling format extensible throughout, where, even when reusing a great amount of document content, it's 'more specific trumps general' cascading rules allow you to mashup/extend/improve the original appearance with minimal code without asking for agreement of the author🤗
    • Shadow DOM - a feature that allows to create restrictions that nullify the openness of CSS, that prevent you from being able to easily change the appearance of an element you haven't wrote
      😲❓
      That's right. If you want to change an appearance of an existent content behind a Shadow DOM, you either need to learn about new mechanisms (CSS Variables which, interestingly, suffers the original problem that encapsulation was trying to solve - variables are global) and ask the author to 'allow you to change the appearance' (he might also need to learn it), or fork your own version, if the component is a self-hostable npm package (but for a truly 'information-sharing-friendly', I'm much more concerned about those shared directly).

    I would like to argue that the fact that your own code is easily able to modify content pre-authored by someone else's is a feature, not a bug. I'd like to point out that it existed since the dawn of the web, and people somehow coped. Perhaps it's because the assumption that "when it happens it's unintentional" is simply much more often untrue than true. Or perhaps it's because when it was truly unintentional, the original CSS features allow user to easily fix the 'intent clash' by adding more specificity to his rules.

    I'm not saying that there isn't a place for Shadow DOM on the web, but I would argue that it does not cater for the common web user, but rather for interest of commercial institutions. I like to be skeptical about Google's will to dominate, but from where I'm standing, it's no wonder why Chrome removed an already implemented feature while it's Polymer foundation heavily preached that the worst evil is 'styles leaking in' and advertising Shadow DOM as the savior, not mentioning scoped CSS in materials that justify its introduction.

  25. locked and limited conversation to collaborators on Feb 10, 2018
  26. sideshowbarker commented on Feb 10, 2018

    @sideshowbarker
    Member

    In the interest of avoiding others deciding this issue is a good place for off-topic comments like #552 (comment), I’ve locked the issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    removal/deprecation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions