Skip to content

Releases: lume/element-behaviors

v5.0.0 - Unglobalization

24 Oct 08:10
Compare
Choose a tag to compare

BREAKING: remove the global build. Migration: if you were importing the dist/global.js file with a script tag, instead use import syntax to import element-behaviors into your project.

Full Changelog: v4.0.0...v5.0.0

v4.0.0

01 Oct 01:14
Compare
Choose a tag to compare

Bite the bullet and commit build outputs so that they are as accessible as possible for people that may not be able to run the build in some OS or setup.

BREAKING:

  • limit the version of solid-js or the build breaks (test in Windows PowerShell)

Full Changelog:

v3.1.0...v4.0.0

v3.1.0 - Sparkles!

30 Jul 20:09
Compare
Choose a tag to compare

This release introduces a elementBehaviors.whenDefined(name) method on the BehaviorRegistry class, similar to the customElements.whenDefined(name) method on the CustomElementRegistry class. The method can be used to wait for a behavior class to be defined before performing logic.

Previous code ordering issues would lead to behaviors not being instantiated if the has="" attribute was defined before the behaviors were defined. Now the has="" attribute uses the new elementBehaviors.whenDefined() method internally to fix this problem by waiting for definitions to exist instead of returning if a definition doesn't exist.

Example:

<script src="https://unpkg.com/[email protected]/dist/global.js"></script>

<h1 has="sparkles">Sparkles!</h1>

<script>
elementBehaviors.whenDefined('sparkles').then(() => {
  console.log('Sparkles are ready!')
})

setTimeout(() => {
  // if the sparkles behavior class gets defined later, then it will be
  // instantiated as expected, and the above console.log will run:
  elementBehaviors.define('sparkles', class {
    // ... add sparkles to host element ...
  })
})
</script>

Full Sparkles demo on CodePen: https://codepen.io/trusktr/pen/MWzzNdV?editors=1000

Screen.Recording.2023-07-30.at.1.06.32.PM.mov

v3.0.2

30 Jul 23:20
Compare
Choose a tag to compare

Fixes/Feature:

  • The element arguments were not being passed into the lifecycle methods as described by the docs. Those are now added.

v3.0.1

30 Jul 23:19
Compare
Choose a tag to compare

Just a README update

v3.0.0

30 Jul 22:48
Compare
Choose a tag to compare

Breaking:

  • Life cycle ordering slightly changed: behaviors are constructed and their connectedCallback executed at the same time, back to back.
  • awaitElementDefined is now a static property, f.e. static awaitElementDefined = true. The non-static property is no longer supported.

Fixes:

  • This slight change in ordering was needed in order for the awaitElementDefined property to work well. Previously, a behavior would be instantiated even if an element was not yet defined, then its connectedCallback fired later after element definition. Now, behaviors will not be instantiated at all, until their host element is defined, upgraded, and connected. Additionally, behaviors will no longer be instantiated and connected at all if their element is removed from DOM before being defined and upgraded.

Features:

Overall this stabilizes the way behaviors work, and it is only a breaking change mainly if you were previously using the awaitElementDefined property, which was previously undocumented.

  • The README has been updated to document the awaitElementDefined property.

v2.3.1

21 Feb 04:49
Compare
Choose a tag to compare
  • fix: make the has attribute type definition appear as an importable module or else consumers can't import the type, and it will instead be ambient/global which we don't want fce189d

v2.3.0

21 Feb 04:28
Compare
Choose a tag to compare
  • add a type definition for the has='' attribute for use with @lume/element 10d4598