Add "smart" initialization behaviour #2

Manually merged
kytta merged 3 commits from smart-autoinit into main 3 months ago
kytta commented 5 months ago
Owner

This PR adds new (auto-)initialization behaviour, inspired by petite-vue. Here's how it works:

  1. Use require, import, or <script> with the default export to include Shareon without initialization
  2. If you want to (auto-)initialize Shareon:
  • use exported default initializeShareon() function in Node

  • use init attribute in script to initialize Shareon in-browser

    <script src="path/to/shareon.js" init>
    
  • or use exported default function

    <script src="path/to/shareon.js"></script>
    <script>initializeShareon()</script>
    

The default version of the package doesn't auto-initialize buttons any more. noinit version of the package is removed altogether.


Some stuff is about to change in the future beta releases of Shareon 2, mainly the file names and format of the exported library code.

This PR adds new (auto-)initialization behaviour, inspired by [petite-vue](https://github.com/vuejs/petite-vue). Here's how it works: 1. Use `require`, `import`, or `<script>` with the default export to include Shareon without initialization 2. If you want to (auto-)initialize Shareon: - use exported default `initializeShareon()` function in Node - use `init` attribute in `script` to initialize Shareon in-browser ```html <script src="path/to/shareon.js" init> ``` - or use exported default function ```html <script src="path/to/shareon.js"></script> <script>initializeShareon()</script> ``` The default version of the package doesn't auto-initialize buttons any more. `noinit` version of the package is removed altogether. --- Some stuff is about to change in the future beta releases of Shareon 2, mainly the file names and format of the exported library code.
kytta added 3 commits 5 months ago
kytta self-assigned this 5 months ago
kytta added this to the v2.0.0 milestone 5 months ago
kytta referenced this issue from a commit 5 months ago
kytta merged commit 3226d8442d into main manually 5 months ago
The pull request has been manually merged as 3226d8442d.
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This pull request currently doesn't have any dependencies.

Loading…
There is no content yet.