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

Vanilla #14

Merged
merged 18 commits into from
Sep 21, 2024
Merged

Vanilla #14

merged 18 commits into from
Sep 21, 2024

Conversation

rockwellll
Copy link
Collaborator

@rockwellll rockwellll commented Sep 20, 2024

This PR introduces another file that can be imported in environments where the document and window are not set. For example, the default import which also includes Stimulus and initializes it is still like this,

import Hellotext from '@hellotext/hellotext`

While if someone wants to exclude Stimulus from starting, they can import the vanilla that only initializes Hellotext.js via

import Hellotext from '@hellotext/hellotext/vanilla`

Session Assignments

This PR allows developers to set the value of the session when initializing the library. Maybe the session was retrieved from another system and the developers wants to reuse that. If that's the case, it's possible to add it as a config parameter.

Hellotext.initialize(':id', {
  session: <some-session>
})

When the value is present Hellotext uses that without dispatching session-set events, otherwise it creates a new one.

Conditional Document accesses

The Cookie class always assumed the presence of the document object, which would have raised issues in non-browser environments, i.e running in a Node.js environment. For this reason, the Cookie class only attempts to set or get values from the document's cookie when the object is defined.

@rockwellll rockwellll self-assigned this Sep 20, 2024
@rockwellll rockwellll merged commit 5644ab0 into main Sep 21, 2024
2 checks passed
@rockwellll rockwellll deleted the stimulus-config branch September 21, 2024 11:04
@rockwellll rockwellll restored the stimulus-config branch September 21, 2024 11:05
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.

1 participant