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

Remove jquery from govspeak #1657

Merged
merged 5 commits into from
Aug 28, 2020
Merged

Remove jquery from govspeak #1657

merged 5 commits into from
Aug 28, 2020

Conversation

andysellick
Copy link
Contributor

@andysellick andysellick commented Aug 21, 2020

What

Remove jquery from govspeak, and associated scripts (youtube link enhancement and bar chart enhancement).

Govspeak relies on magna charta, a jquery plugin, originally included as a minified copy of the code. Magna charta has now been archived, so I've copied the code into the gem and rewritten it as a module without jquery. This has included copying the original tests across from magna charta and rewriting them.

Ultimately we may want to replace magna charta altogether, but this change at least gives us a functioning, non-jquery version that we can apply fixes/changes to if required at any point.

Tests still use jquery in places but jasmine has its own jquery so we don't need to worry about that.

Why

To reduce our dependency on jquery.

Visual Changes

None.

@bevanloon bevanloon temporarily deployed to govuk-publis-remove-jqu-hma5h8 August 21, 2020 09:37 Inactive
@bevanloon bevanloon temporarily deployed to govuk-publis-remove-jqu-hma5h8 August 21, 2020 15:27 Inactive
@bevanloon bevanloon temporarily deployed to govuk-publis-remove-jqu-hma5h8 August 26, 2020 08:49 Inactive
@bevanloon bevanloon temporarily deployed to govuk-publis-remove-jqu-hma5h8 August 27, 2020 08:34 Inactive
@andysellick andysellick force-pushed the remove-jquery-from-govspeak branch from 03eba2c to 15c87bb Compare August 27, 2020 13:00
- relies on magna charta, which is a jquery plugin, so we have to convert the passed element to a jquery object still, but this will be dealt with later
- magna-charta (https://github.com/alphagov/magna-charta) is an archived project and relies on jquery, which we are trying to remove
- this commit introduces a local, unminified copy of the code to the gem and adds a test for it, based on the original code's test: https://github.com/alphagov/magna-charta/blob/master/test/magna-charta_test.js
- the main js file has also been tidied up due to linting requirements
- this has all been done so that we can rewrite magna-charta to not use jquery at a later date
- had to include an option for testing to return a reference to the object, in order not to have to completely rewrite the tests
- at least one test was redundant so have removed, others have been modified
@bevanloon bevanloon temporarily deployed to govuk-publis-remove-jqu-hma5h8 August 27, 2020 13:00 Inactive
@andysellick andysellick force-pushed the remove-jquery-from-govspeak branch from 15c87bb to ce9d4d4 Compare August 27, 2020 13:01
@bevanloon bevanloon temporarily deployed to govuk-publis-remove-jqu-hma5h8 August 27, 2020 13:01 Inactive
@andysellick andysellick marked this pull request as ready for review August 27, 2020 13:04
@andysellick andysellick requested review from alex-ju and injms August 27, 2020 13:05
Copy link
Contributor

@injms injms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this should either:

  • use classList and not run at all in IE < 10
  • not use classList and run in IE < 10

and also

  • capitalise jQuery correctly 😛 😉

- includes a few extra lines of code, but because it worked in IE8 with jquery before it was converted, and the changes to support IE8+ are relatively minor, I'm operating on the principle of 'do no harm'
@andysellick andysellick force-pushed the remove-jquery-from-govspeak branch from ce9d4d4 to b446ca9 Compare August 28, 2020 12:02
@bevanloon bevanloon temporarily deployed to govuk-publis-remove-jqu-hma5h8 August 28, 2020 12:03 Inactive
@andysellick
Copy link
Contributor Author

Thanks @injms. I've gone with use classList and explicitly include the classList polyfill, so it can run in IE8+, which wasn't one of your options, but I'm improvising 😁

Copy link
Contributor

@injms injms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍾

@andysellick andysellick merged commit 439a992 into master Aug 28, 2020
@andysellick andysellick deleted the remove-jquery-from-govspeak branch August 28, 2020 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants