80664[TASK] Streamline applying stylesheets in lit-element components
Commit message
Review
-
Code review CR +2 Done
- Benjamin Franzke +2
- Benjamin Kott +1
-
Verified V +2 Done
- Benjamin Franzke +2
- Benjamin Kott +1
- core-ci +1 CI
Issues 1
Files 17
- Build/Sources/Sass/element/typo3-backend-draggable-resizable.scss+23 −0
- Build/Sources/Sass/element/typo3-backend-security-csp-reports.scssnew+68 −0
- Build/Sources/Sass/element/typo3-backend-security-sudo-mode.scssnew+7 −0
- Build/Sources/Sass/element/typo3-backend-table-wizard.scssnew+3 −0
- Build/Sources/Sass/backend.scss+3 −0
- Build/Sources/TypeScript/backend/element/draggable-resizable-element.ts+0 −14
- Build/Sources/TypeScript/backend/element/spinner-element.ts+9 −11
- Build/Sources/TypeScript/backend/element/table-wizard-element.ts+1 −6
- Build/Sources/TypeScript/backend/security/element/csp-reports.ts+7 −56
- Build/Sources/TypeScript/backend/security/element/sudo-mode.ts+7 −6
- Build/Sources/TypeScript/core/lit-helper.ts+1 −0
- typo3/sysext/backend/Resources/Public/Css/backend.css2+46 −0
- typo3/sysext/backend/Resources/Public/JavaScript/element/draggable-resizable-element.js+1 −2
- typo3/sysext/backend/Resources/Public/JavaScript/element/spinner-element.js+5 −11
- typo3/sysext/backend/Resources/Public/JavaScript/element/table-wizard-element.js+1 −4
- typo3/sysext/backend/Resources/Public/JavaScript/security/element/csp-reports.js+2 −56
- typo3/sysext/backend/Resources/Public/JavaScript/security/element/sudo-mode.js+1 −5
Review log 3248
Show 1523 earlier messages
-
Oliver Hader uploaded patch set 1 08/24/23, 06:58
-
core-ci voted on patch set 1 V +1 08/24/23, 07:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45774
-
Oliver Hader uploaded patch set 2
V +108/24/23, 07:33 -
core-ci voted on patch set 2 V +1 08/24/23, 07:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45777
-
Oliver Hader uploaded patch set 3
V +108/24/23, 09:02 -
Oliver Hader uploaded patch set 4 08/24/23, 09:07
-
core-ci voted on patch set 3 V +1 08/24/23, 09:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45779
-
Oliver Hader uploaded patch set 5 08/24/23, 09:11
-
Oliver Hader commented on patch set 5 08/24/23, 09:12
This change is ready for review. -
core-ci voted on patch set 4 V +1 08/24/23, 09:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45780
-
core-ci voted on patch set 5 V +1 08/24/23, 09:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45781
-
Benjamin Franzke commented on patch set 5 CR -1 08/24/23, 11:27
Thanks, cool idea! We should probably try to encapsulate that into a so-called "mixin". https://lit.dev/docs/composition/mixins/#mixins-in-typescript I can do that if you like, as I'm working on another lit-element for cross-frame-css usage currently. Therefore I'm placing a -1 for now, so we can coordinate. -
Oliver Hader commented on patch set 5 08/24/23, 12:30
Reply
Yeah, that's fine for me. I remember mixins from earlier Polymer days. Using a mixin basically solves this by class inheritance, thus we could move `createRenderRoot` to that class and can can rid of these methods in the current components. For naming, maybe it's a `class OpenLitElement` or `class NonShadowDomLitElement`... I'm not happy yet with the names 😜 -
Oliver Hader uploaded patch set 6
CR -1V +108/24/23, 20:49 -
core-ci voted on patch set 6 V +1 08/24/23, 20:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45804
-
Oliver Hader commented on patch set 6 08/24/23, 21:06
Reply
I've now been using plain inheritance. The mixin approach seems to be superfluous here for the time being. Once there's a demand for having multiple mixins (like traits in PHP), we might consider adding it. -
Oliver Hader uploaded patch set 7
V +108/24/23, 21:06 -
core-ci voted on patch set 7 V +1 08/24/23, 21:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45805
-
Benjamin Franzke commented on patch set 7 08/25/23, 09:22
light-dom-element.ts:56Do you see a possibility to not leak the registered styles forever? I mean, if an element is removed from the DOM, it's style would never be removed right now. Rough idea: keep a reference to the constructed stylesheets of the component, then array_filter document.adoptedStyleSheetrs in disconnectedCallback() to filter out own style objects. -
Oliver Hader uploaded patch set 8
V +108/25/23, 15:04 -
core-ci voted on patch set 8 V +1 08/25/23, 15:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45834
-
Oliver Hader commented on patch set 8 08/25/23, 15:13
light-dom-element.ts:56ReplyI've now added a static map that keeps track of all adopted style sheets for various elements. `styles` is a static property, thus it has to be counted how many instances of a particular element are still active - in case the last one is gone, the adopted style sheets can be dropped again. For the alternative element approach, I just added the `<style>` elements below the component element - this is how it was before, when the it was rendered as template result. ``` html`<style>...</style><div>...</div> ``` I tested the `<style scoped>` property, which did not seem to be working in Chrome. As a result, if there are multiple instances of the same component, the styles will be there multiple times. Anyway, it's just a fall-back and `styles` is still static, so there won't be any variations for the same component. What do you think? -
Oliver Hader wrote 08/30/23, 15:32
Topic set to csp
-
Benjamin Franzke uploaded patch set 9
V +108/31/23, 07:35 -
Benjamin Franzke commented on patch set 9 08/31/23, 07:35
Reply
Just for reference: I liked the fact that using a mixin would directly show what base element class is used (LitElemnt) – I feel like this isn't as self-documenting with LightDomElement.light-dom-element.ts:30It seels like this.windowRef is never set. What is/was the usecase, cross frame operability? I think we could use the following code to make sure we use the "right"/current document and window of the element: const documentRef = this.ownerDocument; // and if really needed const windowRef = documentRef.defaultView; But on the other hand that doesn't make sense to support right now, since Firefox breaks with cross-frame web component usage anyway. See https://forge.typo3.org/issues/101747#note-4 for more info. Anyway I went with ownerDocument now, as this is always correct.light-dom-element.ts:56ReplyThanks for the map. <style scoped> is deprecated and would actually not work for such styles that target the current elements tag name `typo3-foo-bar { }`, so I removed it for such both reasons.light-dom-element.ts:83Btw, it's hard to find a Browser that works with TYPO3 v12 but does *not* supports constructable/adoptable stylesheets. Fine to leave this in for v12 – but I had to test it manually by emulating missing constructable stylesheet support. For main we should remove that rather sooner than later. Note that lit does support this for the sake of IE11 and old Firefox support, which we do not have. We do not support IE11 and Firefox 102 ESR already support constructable stylesheets. -
core-ci voted on patch set 9 V +1 08/31/23, 07:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46065
-
Benjamin Kott commented on patch set 9 CR -2 09/15/23, 06:13
For what i am seeing right now, this patch tries to mitigate a problem with CSP and nonce. In most cases we are not really entering a shadow-dom scenario that means we can also just global style the elements like with already do with others. It currently looks like a scoped definition (shadow-dom) but is is not, in addition we are facing here a general problem with flash of unstyled content since we also need to define the defaults for shadow-dom elements mostly related to display in the global css anyway. So i would suggest to move light dom completly and remove the css from elements where we cannot apply a full shadow dom. -
Oliver Hader commented on patch set 9 09/15/23, 07:35
Reply
This change actually gets rid of the `window.litNonce` helper (which already exists in TYPO3 v12). The goal is to avoid using nonces in general - however, for CSP `strict-dynamic` (just one example of many), it is required to use nonces or hashes when creating inline styles. Thus, using constructed stylesheets - which is not only specified for shadow-dom, but for regular documents (light-dom) as well - using inline styles in components can be avoided. And that is what this change is doing. If I understood it correctly, your suggestion is to completely & radically throw out all styles from light-dom components and put it to some `backend.css` instead? > [...] in addition we are facing here a general problem with flash of unstyled content since we also need to define the defaults for shadow-dom [...] I did not really understood this statement. Can you please explain that or point to some examples? Thx! -
Oliver Hader uploaded patch set 10
CR +1V +109/18/23, 10:39Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR is:MIN") -
core-ci voted on patch set 10 V -1 09/18/23, 10:48 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46652
-
Oliver Hader uploaded patch set 11
V -109/18/23, 10:54Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR is:MIN") -
core-ci voted on patch set 11 V +1 09/18/23, 11:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46654
-
Oliver Hader uploaded patch set 12
V +109/18/23, 13:51Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR is:MIN") -
Oliver Hader commented on patch set 12 09/18/23, 13:54
backend.css:3831This does not look correct. @BenjaminKott: Can you please have a look at the `@container` things in `csp-reports.scss`? Thx! -
core-ci voted on patch set 12 V +1 09/18/23, 13:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46670
-
Oliver Hader uploaded patch set 13
V +109/18/23, 14:18Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR is:MIN") -
core-ci voted on patch set 13 V +1 09/18/23, 14:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46674
-
Oliver Hader uploaded patch set 14
V +109/18/23, 19:21Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR is:MIN") -
Oliver Hader commented on patch set 14 09/18/23, 19:24
backend.css:3831ReplyDone & what a nightmare... PhpStorm was changing formatting and added some spaces... and now knowing that `@container` is purged by clean-css made that work now. -
core-ci voted on patch set 14 V -1 09/18/23, 19:28 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46707
-
Oliver Hader uploaded patch set 15
V -109/18/23, 19:36Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR is:MIN") -
core-ci voted on patch set 15 V +1 09/18/23, 19:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46708
-
Oliver Hader commented on patch set 15 09/18/23, 19:49
Reply
Done -
Benjamin Franzke uploaded patch set 16
V +109/19/23, 08:43Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR is:MIN") -
Benjamin Kott voted on patch set 16 V +1 CR +1 09/19/23, 08:47
-
Benjamin Franzke voted on patch set 16 V +2 CR +2 09/19/23, 08:49
-
core-ci voted on patch set 16 V +1 09/19/23, 08:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46740
-
Benjamin Franzke merged patch set 17 09/19/23, 08:59