This PR introduces a new settings which allows our plugin to initialize widgets that are dynamically added to the page after load. This includes popups, multi-step forms and generally content loaded with AJAX.
We achieve this by adding a MutationObserver to the document body which looks for new nodes being added to the DOM. It then initializes any element with the .frc-captcha class if it doesn't have the friendlyChallengeWidget property which is added by the friendly-challenge library.
We look for the friendlyChallengeWidget property instead of the data-attached attribute because the latter persists when HTML is removed and added back to the DOM.
This is opt-in because it could potentially affect the performance of the page. After all we are running a bit of code whenever a new node is added to the DOM.
This PR introduces a new settings which allows our plugin to initialize widgets that are dynamically added to the page after load. This includes popups, multi-step forms and generally content loaded with AJAX.
We achieve this by adding a MutationObserver to the document body which looks for new nodes being added to the DOM. It then initializes any element with the
.frc-captcha
class if it doesn't have thefriendlyChallengeWidget
property which is added by the friendly-challenge library. We look for thefriendlyChallengeWidget
property instead of thedata-attached
attribute because the latter persists when HTML is removed and added back to the DOM.This is opt-in because it could potentially affect the performance of the page. After all we are running a bit of code whenever a new node is added to the DOM.