-
Notifications
You must be signed in to change notification settings - Fork 20
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
Conversation
03eba2c
to
15c87bb
Compare
- 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
15c87bb
to
ce9d4d4
Compare
app/assets/javascripts/govuk_publishing_components/components/govspeak.js
Outdated
Show resolved
Hide resolved
app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
Outdated
Show resolved
Hide resolved
app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
Outdated
Show resolved
Hide resolved
app/assets/javascripts/govuk_publishing_components/lib/govspeak/magna-charta.js
Outdated
Show resolved
Hide resolved
app/assets/javascripts/govuk_publishing_components/lib/govspeak/magna-charta.js
Outdated
Show resolved
Hide resolved
app/assets/javascripts/govuk_publishing_components/lib/govspeak/magna-charta.js
Show resolved
Hide resolved
There was a problem hiding this 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'
ce9d4d4
to
b446ca9
Compare
Thanks @injms. I've gone with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍾
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.