Skip to content

Commit

Permalink
Call element in parent function of the module
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Aug 14, 2022
1 parent 9c54986 commit bfe8efc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions x-govuk/components/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ module.exports = (function () {
const started = element.dataset.moduleStarted

if (typeof GOVUKPrototypeComponents[name] === 'function' && !started) {
module = new GOVUKPrototypeComponents[name]()
module.init(element)
module = new GOVUKPrototypeComponents[name](element)
module.init()
element.dataset.moduleStarted = true
}
})
Expand Down
4 changes: 2 additions & 2 deletions x-govuk/components/autocomplete/autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const accessibleAutocomplete = require('accessible-autocomplete')

module.exports = function () {
this.init = ($module) => {
module.exports = function ($module) {
this.init = () => {
// Autocomplete options get passed from Nunjucks params to data attributes
const params = $module.dataset

Expand Down
4 changes: 2 additions & 2 deletions x-govuk/components/edge/edge.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const events = require('eventslibjs')

module.exports = function () {
this.init = ($module) => {
module.exports = function ($module) {
this.init = () => {
const nodes = $module.querySelectorAll('a[href="#"]')
nodes.forEach(node => { events.on('click', node, alertUser) })

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = function () {
this.init = ($module) => {
module.exports = function ($module) {
this.init = () => {
let hasChanged = false

$module.addEventListener('submit', () => {
Expand Down

0 comments on commit bfe8efc

Please sign in to comment.