Review main Merged

67092[FEATURE] Introduce lit-html & lit-element as client-side template engine

Benjamin Franzke CR +2 V +2 Hard +744 −5 updated 12/18/20, 00:02

Commit message

Add the lit-html template engine, that originated from
the polymer project and is now base for web components
together with the web component base case LitElement.

It is used to replace string-concatenation/jquery based
templating in order to adapt to modern web standards.

typo3/testing-framework is adapted to include lit-html and
lit-element with:
https://github.com/TYPO3/testing-framework/pull/221
(releases as 6.6.0 and merged in #93074)

Commands:

  yarn add lit-html@^1.3 lit-element@^2.4
  yarn add --dev grunt-rollup
  grunt build

Review

  • Code review CR +2 Done
    • Oliver Hader +2
  • Verified V +2 Done
    • Oliver Hader +2
    • TYPO3com +1 CI

Issues 2

Files 39

Show 19 more files

Review log 4065

Show 2340 earlier messages
  1. Benjamin Franzke uploaded patch set 1 12/11/20, 12:03

  2. TYPO3com voted on patch set 1 V -1 12/11/20, 12:13 Completed build in 09m 03s on Fri, 11 Dec, 12:13 PM Test Summary: 3 of 32654 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8062

  3. Benjamin Franzke uploaded patch set 2 12/11/20, 12:57

  4. TYPO3com voted on patch set 2 V -1 12/11/20, 13:08 Completed build in 11m 12s on Fri, 11 Dec, 01:08 PM Test Summary: 3 of 32637 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8064

  5. Benjamin Franzke uploaded patch set 3 12/11/20, 13:24

  6. TYPO3com voted on patch set 3 V -1 12/11/20, 13:36 Completed build in 11m 35s on Fri, 11 Dec, 01:36 PM Test Summary: 3 of 32654 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8068

  7. Benjamin Franzke uploaded patch set 4 12/11/20, 13:37

  8. TYPO3com voted on patch set 4 V +1 12/11/20, 13:48 Completed build in 10m 57s on Fri, 11 Dec, 01:48 PM Test Summary: 32412 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8070

  9. Benjamin Franzke uploaded patch set 5 12/11/20, 14:05

  10. TYPO3com voted on patch set 5 V +1 12/11/20, 14:16 Completed build in 10m 00s on Fri, 11 Dec, 02:16 PM Test Summary: 32411 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8074

  11. Benjamin Franzke uploaded patch set 6 12/11/20, 14:25

  12. Benjamin Franzke commented on patch set 6 CR -1 12/11/20, 14:28

  13. Oliver Hader commented on patch set 6 CR -1 12/11/20, 14:35

    Please let me finish my other task in https://review.typo3.org/c/Packages/TYPO3.CMS/+/65048 and then you can refactor whatever you like to refactor
  14. TYPO3com voted on patch set 6 V +1 12/11/20, 14:35 Completed build in 10m 03s on Fri, 11 Dec, 02:35 PM Test Summary: 32413 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8078

  15. Oliver Hader commented on patch set 6 CR -2 12/11/20, 14:41

  16. Benjamin Franzke commented on patch set 6 12/11/20, 14:42

    Reply

    ..is reverted

    Reply

    I would like to revert the original patch instead and then re-introduce native lit-html, therefore I like to rebase your FormEngine patch (65048) on lit-html before we merge that.
  17. Benjamin Franzke commented on patch set 6 12/11/20, 14:44

    Reply

    I didn't want to repeat the lit-html template reference too much, therefore I added a link to the template reference. But sure, no examples is probably a bit too less. Will fix.
  18. Oliver Hader voted on patch set 6 CR -1 12/11/20, 14:56

  19. Benjamin Franzke uploaded patch set 7 12/11/20, 15:29

  20. Benjamin Franzke uploaded patch set 8 12/11/20, 15:36

  21. TYPO3com voted on patch set 7 V +1 12/11/20, 15:42 Completed build in 10m 59s on Fri, 11 Dec, 03:42 PM Test Summary: 32413 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8083

  22. TYPO3com voted on patch set 8 V +1 12/11/20, 15:45 Completed build in 08m 56s on Fri, 11 Dec, 03:45 PM Test Summary: 32413 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8084

  23. Benjamin Franzke uploaded patch set 9 12/11/20, 20:45

  24. TYPO3com voted on patch set 9 V -1 12/11/20, 20:59 Completed build in 13m 18s on Fri, 11 Dec, 08:59 PM Test Summary: 16 of 32536 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8098

  25. Benjamin Franzke uploaded patch set 10 12/12/20, 06:02

  26. TYPO3com voted on patch set 10 V -1 12/12/20, 06:12 Completed build in 09m 59s on Sat, 12 Dec, 06:12 AM Test Summary: 15 of 32654 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8105

  27. Benjamin Franzke uploaded patch set 11 12/12/20, 06:52

  28. TYPO3com voted on patch set 11 V -1 12/12/20, 07:04 Completed build in 11m 46s on Sat, 12 Dec, 07:04 AM Test Summary: 27296 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8106

  29. TYPO3com commented on patch set 11 12/12/20, 07:16 Completed build in 10m 20s on Sat, 12 Dec, 07:16 AM Test Summary: 2 of 32653 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8107

  30. TYPO3com voted on patch set 11 V +1 12/12/20, 07:46 Completed build in 10m 00s on Sat, 12 Dec, 07:46 AM Test Summary: 32411 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8108

  31. Benjamin Franzke uploaded patch set 12 12/12/20, 13:05

  32. TYPO3com voted on patch set 12 V +1 12/12/20, 13:17 Completed build in 12m 19s on Sat, 12 Dec, 01:17 PM Test Summary: 32414 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8117

  33. Benjamin Franzke uploaded patch set 13 12/12/20, 16:32

  34. TYPO3com voted on patch set 13 V +1 12/12/20, 16:45 Completed build in 12m 54s on Sat, 12 Dec, 04:45 PM Test Summary: 32414 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8124

  35. Benjamin Franzke uploaded patch set 14 12/12/20, 21:49

  36. TYPO3com voted on patch set 14 V +1 12/12/20, 22:00 Completed build in 10m 37s on Sat, 12 Dec, 10:00 PM Test Summary: 32414 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8129

  37. Benjamin Franzke uploaded patch set 15 12/14/20, 13:19

  38. Benjamin Franzke commented on patch set 15 12/14/20, 13:23

    This change is ready for review.
    This one is ready for review. But we should merge the revert of the initial template approach before: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67095
  39. TYPO3com voted on patch set 15 V +1 12/14/20, 13:32 Completed build in 13m 00s on Mon, 14 Dec, 01:32 PM Test Summary: 32415 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8161

  40. Benjamin Franzke uploaded patch set 16 12/14/20, 13:37

  1. TYPO3com voted on patch set 16 V +1 12/14/20, 13:48 Completed build in 11m 14s on Mon, 14 Dec, 01:48 PM Test Summary: 32415 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8163

  2. Benni Mack commented on patch set 16 12/15/20, 09:46

    ext_localconf.php:74

    shouldn't we move this into EXT:backend?
  3. Benjamin Franzke uploaded patch set 17 12/15/20, 09:57

  4. Benjamin Franzke commented on patch set 17 12/15/20, 09:57

    ext_localconf.php:74 Reply

    Ack
  5. TYPO3com voted on patch set 17 V +1 12/15/20, 10:13 Completed build in 15m 58s on Tue, 15 Dec, 10:13 AM Test Summary: 32412 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8189

  6. Benjamin Franzke uploaded patch set 18 12/16/20, 21:06

  7. TYPO3com voted on patch set 18 V +1 12/16/20, 21:16 Completed build in 10m 08s on Wed, 16 Dec, 09:16 PM Test Summary: 32433 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8218

  8. Oliver Hader commented on patch set 18 12/17/20, 11:43

    Gruntfile.js:479

    How could we ensure that added/removed files in a future release of `lit-html` are reflected here?

    LiveSearch.ts:102

    I was thinking about this pattern a bit (create temp node for composing inner details). `TemplateResult.getHTML` might be used directly here - however when focussing on the long-term goals, still `render` might be better, since it maintains state (caches) internally allowing data-binding. For this particular case data-binding is superfluous, as long as we still have lots of functions that either expect raw string HTML or jQuery "nodes". Thus, it would be filling the cache without actually being used → probably higher memory consumption when using this pattern for various scenarios.

    LiveSearch.ts:120 Unresolved

    I'll double check lit's behavior for NodePart vs AttributePart here - I'm pretty sure XSS is not possible, but I have to "see it with my own eyes" ;)

    Notification.ts:163

    Web Animations via JavaScript is still a draft - it feels this fade-in/fade-out would be used more often and requires a new custom `animate` directive - as a strategy facade for either WebAnimation/JS, jQuery or CSS transitions...

    NotificationTest.ts:80

    Could that delay be avoided completely, since we await the `updateComplete` life-cycle promise to be finished already?

    LiveSearch.php:222

    Seems `typeLabel` is not to be used client-side, is it?

    PageRenderer.php:1507

    Why & what's the difference here? Probably add a comment...
  9. Benjamin Franzke commented on patch set 18 12/17/20, 14:11

    Thank you for your review.

    Gruntfile.js:479 Reply

    Yea, I wasn't sure what we want here. The Gruntfile is very explicit regarding the copied files in other places like for jquery-ui as well, therefore I've tried to keep the pattern of "name every file explicitly". I would be fine with autogenerating this list. We would only need to life with empty modules being added as well (I mean thats what happens for EXT:core/Resources/Public/JavaScript/Event/EventInterface.js as well). And then it would be usefull to also delete possibly deleted files.

    LiveSearch.ts:102 Reply

    Hm, yea, I wanted to use `TemplateResult.getHTML` as well, but the HTML contains markers like `<!--{{lit-8700743881662687}}-->` and *not* the values, that's because lit-html replaces these (of course escaped) via DOM API during render(). Therefore a "real" rendering with render() on a DOM element is actually needed. But you are right, it's always preferable to directly render to elements instead of rendering to temporary elements just to convert to string afterwards. …But I think data-binding is not superfluous here, LiveSearch may happen multiple times, therefore the HTML template can be cached by lit-html. Also data-binding really serves as XSS protection IMO.

    Notification.ts:163 Reply

    Yea, it's a draft, but it's so much more fluent than jQuery's manual timeout based animation.. 😊 Generalizing this might be useful, yes. With `directive` you mean a lit-html directive, or a general helper class? Sounds like you have something in mind? If we decide against web animations api, then we'd need to keep using $.fn.slideUp() is in patchset 13: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67092/13/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Notification.ts

    NotificationTest.ts:80 Reply

    It is actually still needed here. The test on the next line verifies that the notification will be hidden (automatically) and therefore the timeout needs to be "waited" for before that check can happen.

    LiveSearch.php:222 Reply

    It's used to group the search results in LiveSearch.ts (passed as `groupBy: 'typeLabel'` to $.fn.autocomplete`). This label is then passed as argument `category` to `formatGroup` and there it is renderer to HTML via lit-html (and therefore it is escaped client side and thatswhy htmlspecialchars is removed here).

    PageRenderer.php:1507 Reply

    I've added it to the PageRendererTest. This is because requirejs 'packages' configuration requires a numeric indexed array (while all other requirejs configuration is string-indexed). So this case (a 'package' in 'public' didn't happen when you added the public vs non-public), and therefore we need to switch aways from array_replace_recursive. Now, with lit-html and lit-element in ['public']['packages'], the package definition for codemirror (added in EXT:t3editor/Classes/Hook/PageRendererRenderPreProcess.php) would otherwise overwrite the public definitions of lit-html. When public and non-public configurations are "replaced" (instead of merged) here. So we need array_merge for numeric-indexed arrays and array_replace_recursive, for string-indexed arrays. Therefore the switch to `replaceAndAppendScalarValuesRecursive`.
  10. Benjamin Franzke uploaded patch set 19 12/17/20, 19:09

  11. Benjamin Franzke commented on patch set 19 12/17/20, 19:09

    Gruntfile.js:479 Reply

    Changed to use glob's for lib/*.js and directives/*.js.

    NotificationTest.ts:80 Reply

    Added a comment to the code.

    PageRenderer.php:1507 Reply

    Added a comment to the method call.
  12. TYPO3com voted on patch set 19 V +1 12/17/20, 19:20 Completed build in 10m 09s on Thu, 17 Dec, 07:20 PM Test Summary: 32496 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8233

  13. Oliver Hader commented on patch set 19 12/17/20, 21:31

    LiveSearch.ts:102 Reply Unresolved

    I see... context-based rendering (to avoid XSS) happens in AttributePart and NodePart. I'll create some `renderHTML` function for that...

    Notification.ts:163 Reply Unresolved

    I had something like https://angular.io/guide/animations#code-review in mind, or https://www.webcomponents.org/element/@polymer/neon-animation/elements/fade-in-animation However that seems to be a little bit more complicated since we're using light-DOM and encapsulated shadow-CSS would not work with it...

    LiveSearch.php:222 Reply

    Ack
  14. Oliver Hader uploaded patch set 20 12/17/20, 21:45

  15. Oliver Hader commented on patch set 20 12/17/20, 21:48

    Double checked attribute encoding... I don't have any other/better idea for animations - however it seems that Web Animation L2 API is supported by all browsers matching the min. requirements for TYPO3 v11.
  16. TYPO3com voted on patch set 20 V -1 12/17/20, 21:58 Completed build in 12m 57s on Thu, 17 Dec, 09:58 PM Test Summary: 2 of 29265 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8234

  17. TYPO3com voted on patch set 20 V +1 12/17/20, 22:26 Completed build in 53m 38s on Thu, 17 Dec, 10:26 PM Test Summary: 32496 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8234

  18. Oliver Hader commented on patch set 20 V -1 12/17/20, 22:53

    Something seems to be wrong with ContextMenu (and I am not able to spot it). Using the context menu in page-tree and showing info-popup of a page gives me 4 instances of that modal - I can close the 1st using the `x` button, the remaining can only be closed using ESC key. Not applying the ContextMenu.ts changes "solved" the problem... It might be related to the mix of lit-html and jQuery towards event handling - however, I did not spot any obvious flaw in the code here...
  19. Oliver Hader uploaded patch set 21 12/17/20, 23:01

  20. Oliver Hader commented on patch set 21 12/17/20, 23:02

    Removed the integrations for the time being and will re-add them as separated patches
  21. TYPO3com voted on patch set 21 V -1 12/17/20, 23:16 Completed build in 14m 37s on Thu, 17 Dec, 11:16 PM Test Summary: 1 of 31911 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8236

  22. Oliver Hader voted on patch set 21 V +1 CR +1 12/17/20, 23:21

  23. TYPO3com voted on patch set 21 V +1 12/17/20, 23:30 Completed build in 43m 41s on Thu, 17 Dec, 11:30 PM Test Summary: 32496 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8236

  24. Oliver Hader voted on patch set 21 V +2 CR +2 12/18/20, 00:02

  25. Oliver Hader merged patch set 22 12/18/20, 00:02