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

Add blurb in README for executing target <script> tags on swap? #16

Open
figuerom16 opened this issue Feb 28, 2025 · 0 comments
Open

Add blurb in README for executing target <script> tags on swap? #16

figuerom16 opened this issue Feb 28, 2025 · 0 comments

Comments

@figuerom16
Copy link

figuerom16 commented Feb 28, 2025

I use Surreal for Locality of Behavior so replacing the script tags to get them to execute is a must for me. Other people who deliver JS in their template fragments might find it useful if they don't mind dealing with the problems that come with it. Some style of this as an addition the README?

document.addEventListener('fx:swapped', (evt) => {
	evt.detail.cfg.target.querySelectorAll('script').forEach(s =>
		s.replaceWith(Object.assign(document.createElement('script'),{textContent:s.textContent}))
	)
})
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

No branches or pull requests

1 participant