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 option to not include the Data API initialization code #214

Merged
merged 2 commits into from
May 11, 2018

Conversation

marcelpanse
Copy link
Contributor

We use bootstrap native to build a component. This component can be used on our clients' websites by including our javascript file. As soon as they include our library, bootstrap-native will start searching the entire DOM tree to find data- elements and start initializing them. This will have unintended side-effects. We only want to initialize our own inserted DOM elements programmatically, so I added an option to exclude the utils-init.js code.
This solved #180

@thednp
Copy link
Owner

thednp commented May 11, 2018

We would also need this stuff for V3 as well, also some documentation update should also be taken into account.

@marcelpanse
Copy link
Contributor Author

marcelpanse commented May 11, 2018 via email

@thednp
Copy link
Owner

thednp commented May 11, 2018

I would rename the option to autoInitDataAPI and set this option to true by default.

@marcelpanse
Copy link
Contributor Author

I changed the option to autoInitDataAPI and made it true by default.
I added it to the v3 version as well.

Lastly, I updated the wiki page with the new option but reverted it again since this PR is not merged yet (you can see it in the history what I wanted to change).

Let me know if there is anything else you need to get this merged.

@thednp thednp merged commit 1d8c4a0 into thednp:master May 11, 2018
@marcelpanse
Copy link
Contributor Author

@thednp Awesome, thanks! Could you build and publish a new version to NPM so I can use it?

@midzer
Copy link
Contributor

midzer commented May 11, 2018

@marcelpanse you can use latest master in your package.json by putting thednp/bootstrap.native in your bootstrap.native version field.

@marcelpanse
Copy link
Contributor Author

marcelpanse commented May 12, 2018 via email

@thednp
Copy link
Owner

thednp commented May 12, 2018

I added a note on the wiki page, please confirm it's validity. Thanks

@marcelpanse
Copy link
Contributor Author

marcelpanse commented May 12, 2018 via email

@thednp
Copy link
Owner

thednp commented May 13, 2018

One more thing: what would be the most common use cases for this implementation? I'm thinking about mentioning those in the wikies as well.

@marcelpanse
Copy link
Contributor Author

marcelpanse commented May 13, 2018

If you are making a component that can be included on any page (like a widget/bar/popup/carousel/etc) then you'd want that component to be as small as possible but still have the benefits of using the Bootstrap components, so you use bootstrap.native.
Your component runs on a 3rd party website which you have no control over and might already use Bootstrap. To not influence the surrounding website you should set the autoInitDataAPI to false to make sure not to trigger other data- elements on the page by accident (which could have side-effects).

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

Successfully merging this pull request may close these issues.

3 participants