-
Notifications
You must be signed in to change notification settings - Fork 26
Labels
bugUnexpected problem or unintended behavior that impairs normal functioning.Unexpected problem or unintended behavior that impairs normal functioning.
Description
Expected Behaviour
Whether registering an event listener before or after adobe-client-data-layer.min.js has loaded, the callback function should fire just once
Actual Behaviour
When registering an event listener before adobe-client-data-layer.min.js has loaded, the callback function fires twice (fires just once when registering it after the library has loaded)
Reproduce Scenario (including but not limited to)
Steps to Reproduce
Navigate to about:blank in a browser
Execute the following in the console (registers the callback before the library loads)
window.adobeDataLayer = []
instance = 1
var myHandler = function(event) {
console.log('Instance: ' + instance)
console.log(event)
instance+=1
}
window.adobeDataLayer.push(function(dl) {
dl.addEventListener(
"adobeDataLayer:event",
myHandler
)
})
window.adobeDataLayer.push({'event':'newEvent','context':'test'})
scriptElement = document.createElement('script');
scriptElement.src="https://unpkg.com/@adobe/adobe-client-data-layer@1.0.0/dist/adobe-client-data-layer.min.js";
document.body.append(scriptElement)
(Optional) Execute the following in the console (registers the callback after the library loads)
window.adobeDataLayer = []
window.adobeDataLayer.push({'event':'newEvent','context':'test'})
scriptElement = document.createElement('script');
scriptElement.src="https://unpkg.com/@adobe/adobe-client-data-layer@1.0.0/dist/adobe-client-data-layer.min.js";
document.body.append(scriptElement)
instance = 1
var myHandler = function(event) {
console.log('Instance: ' + instance)
console.log(event)
instance+=1
}
window.adobeDataLayer.push(function(dl) {
dl.addEventListener(
"adobeDataLayer:event",
myHandler
)
})
Platform and Version
Chrome 83.0.4103.116
Sample Code that illustrates the problem
Logs taken while reproducing problem
Metadata
Metadata
Assignees
Labels
bugUnexpected problem or unintended behavior that impairs normal functioning.Unexpected problem or unintended behavior that impairs normal functioning.