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

Removed decorate*() js functions #3410

Merged
merged 4 commits into from
Oct 21, 2023
Merged

Removed decorate*() js functions #3410

merged 4 commits into from
Oct 21, 2023

Conversation

fballiano
Copy link
Contributor

M1 had 4 decorate*() javascript functions, that are used (mostly) to add even/odd classes to HTML tables and things like that. The removal of these functions was discussed a couple of times already:

This PR:

  • removes all the calls to decorate*() funcions from the phtml templates
  • deprecates the 4 javascript functions in js/varien/js.js and empties the function "body"

Since the functions are not removed by this PR it's technically not a breaking change but... it changes the final rendering of the pages so... I'd still merge this in the next branch.

This could also be considered a small step forwards removing prototypejs.

Fixes #3043

@github-actions github-actions bot added Component: PayPal Relates to Mage_Paypal Component: Catalog Relates to Mage_Catalog Component: Reports Relates to Mage_Reports Component: CatalogInventory Relates to Mage_CatalogInventory Component: Checkout Relates to Mage_Checkout Component: Sales Relates to Mage_Sales Component: Customer Relates to Mage_Customer Template : rwd Relates to rwd template Template : base Relates to base template Component: Tag Relates to Mage_Tag Component: Wishlist Relates to Mage_Wishlist Component: Shipping Relates to Mage_Shipping Component: Review Relates to Mage_Review Component: Oauth Relates to Mage_Oauth Component: Downloadable Relates to Mage_Downloadable Component: Bundle Relates to Mage_Bundle Component: CatalogSearch Relates to Mage_CatalogSearch Component: Rss Relates to Mage_Rss JavaScript Relates to js/* labels Jul 26, 2023
@addison74 addison74 changed the title Deprecated decorate*() js funcions Deprecated decorate*() js functions Jul 26, 2023
@addison74
Copy link
Contributor

I agree. Do you have in plan a replacement to keep the same behavior?

@fballiano
Copy link
Contributor Author

not at the moment (didn't have time yet) but I think it could be added :-)

@fballiano fballiano marked this pull request as draft July 26, 2023 15:21
@addison74
Copy link
Contributor

It is fine to set this PR as a draft until there is a solution adapted to our days fir what we are removing here.

@fballiano
Copy link
Contributor Author

fballiano commented Jul 26, 2023

"restore the same behavior" only means checking that RWD has correct CSS classes for even/odd styling (because the base theme doesn't have styling anyway), but I think that in RWD we didn't have even/odd styles already, check these couple of screenshot that are taken from the main branch:

Screenshot 2023-07-26 alle 16 30 17 Screenshot 2023-07-26 alle 16 30 12

you can see there was no even/odd styling already

@addison74
Copy link
Contributor

This could also be considered a small step forwards removing prototypejs.

At some point we may be able to do this, but I'm worried about the extensions that use this library. I have so far five in production, either I should make a conversion to jQuery (the fastest way) or to JavaScript (a little more complicated and time-consuming).

If I don't adopt any of the solutions, then I can keep the library and add it manually for functionality. What if we removed everything that is old in OpenMage, including this library and it would be added by those who need it with Composer?

@fballiano
Copy link
Contributor Author

the functions are still there, so there will be no break, but yes you'll lose the functionality. I think that who really needs these functions can just copy them and put them in their javascripts ;-) although for sure somebody has created a library for that.

@fballiano fballiano marked this pull request as ready for review July 28, 2023 11:38
@sreichel
Copy link
Contributor

but yes you'll lose the functionality

Should even/odd/first/last be added to CSS-files to keep current output?

@loekvangool
Copy link
Contributor

Should even/odd/first/last be added to CSS-files to keep current output?

I think they were talking about removing Prototype.js as a whole, which would lead to issues with 3rd party extension beyond CSS classes.

@fballiano
Copy link
Contributor Author

Should even/odd/first/last be added to CSS-files to keep current output?

RWD doesn't have even/odd stripes already, as shown in the screenshots.

@loekvangool
Copy link
Contributor

RWD doesn't have even/odd stripes already, as shown in the screenshots.

There is an impact, but it's mostly marginal.

@fballiano
Copy link
Contributor Author

@loekvangool the only one is in skin/adminhtml/default/default/boxes.css (the other ones as alread CSS based even/odd ;-)) I can for sure take a look at skin/adminhtml/default/default/boxes.css no problem

@loekvangool
Copy link
Contributor

There are a couple more hits in boxes.css, but yeah it's barely anything.

There's also a CSS class zebra-table that does it the CSS way, but it looks unused.

@sreichel
Copy link
Contributor

sreichel commented Aug 1, 2023

Should even/odd/first/last be added to CSS-files to keep current output?

RWD doesn't have even/odd stripes already, as shown in the screenshots.

Your're right for RWD, but PR removes it from "base" template.

I know other themes have been removed, but i know some stores that rely on modern theme ... is this a sure shot?

@fballiano
Copy link
Contributor Author

base template doesn't have CSS so we can't add any CSS to that, and it makes no sense in 2023 to add even odd classes via php.

nth-child is extremely widely supported since years: https://www.w3schools.com/CSSref/sel_nth-child.php

and we're talking about "next".

@fballiano
Copy link
Contributor Author

fballiano commented Aug 1, 2023

RWD doesn't have even/odd stripes already, as shown in the screenshots.

There is an impact, but it's mostly marginal.

@loekvangool seems grids work fine anyway with this PR:
Screenshot 2023-08-01 alle 08 39 27

because those even/odd classes are injected via PHP, so I'd say there's should be nothing to add to this PR.

@loekvangool
Copy link
Contributor

Indeed

@sreichel
Copy link
Contributor

sreichel commented Aug 3, 2023

"nth-child" ... this is why i asked for. I thought even/odd/... has to be changed in CSS files.

@addison74
Copy link
Contributor

addison74 commented Aug 3, 2023

I have not tested this PR and I will not approve it without being convinced that the change is mandatory. Those functions apply to many classes/IDs of some elements in the page. For example class/ID "product_comparison", I need to see the effect in the browser before and after the change. All these elements may need to be added to the CSS/SCSS files to keep the decoration effect.

@addison74 addison74 self-assigned this Aug 3, 2023
@fballiano
Copy link
Contributor Author

I don't think there's anything that could be added in the CSS, base doesn't have css, adminhtml and rwd don't use that functionality.
also, this PR targets next, where I think it's correct to remove 100 javascript calls that were needed years ago but it's much more performant to do the same thing via css instead of js.

@kyrena
Copy link
Contributor

kyrena commented Aug 4, 2023

Can I suggest a console.warn('decorateXyz is deprecated'); to force developers to update code?

@fballiano fballiano changed the title Deprecated decorate*() js functions Removed decorate*() js functions Sep 19, 2023
@fballiano
Copy link
Contributor Author

After #3526 got merged maybe we can merge this one in the next branch ;-)

@elidrissidev elidrissidev linked an issue Oct 11, 2023 that may be closed by this pull request
@fballiano fballiano merged commit abf4ef9 into OpenMage:next Oct 21, 2023
@fballiano fballiano deleted the decorate branch October 21, 2023 11:03
@sreichel sreichel changed the title Removed decorate*() js functions Removed decorate*() js functions Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Bundle Relates to Mage_Bundle Component: Catalog Relates to Mage_Catalog Component: CatalogInventory Relates to Mage_CatalogInventory Component: CatalogSearch Relates to Mage_CatalogSearch Component: Checkout Relates to Mage_Checkout Component: Customer Relates to Mage_Customer Component: Downloadable Relates to Mage_Downloadable Component: Oauth Relates to Mage_Oauth Component: PayPal Relates to Mage_Paypal Component: Reports Relates to Mage_Reports Component: Review Relates to Mage_Review Component: Rss Relates to Mage_Rss Component: Sales Relates to Mage_Sales Component: Shipping Relates to Mage_Shipping Component: Tag Relates to Mage_Tag Component: Wishlist Relates to Mage_Wishlist JavaScript Relates to js/* next-only Template : base Relates to base template Template : rwd Relates to rwd template
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate decorate*() JS functions
8 participants