Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/*

!src/
!pkg/
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
},
"scripts": {
"build": "pack build",
"test": "testee test/connect.html test/disconnect.html test/change.html --browsers firefox"
"test": "testee test/connect.html test/disconnect.html test/change.html --browsers firefox",
"prepare": "npm run build"
},
"repository": {
"type": "git",
Expand Down
3 changes: 1 addition & 2 deletions src/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ class CustomAttributeRegistry {
}
}
// Attribute was removed
else if(newVal == null && !!inst.value) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example: if a custom attribute is some-attribute="", and then it gets removed, the newVal will be null, and the current inst.value will "" which is falsy, which then causes the conditional to incorrectly skip calling disconnectedCallback.

inst.value = newVal;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reasoning here is that this.value will show the last value that the Custom Attribute had while being disconnected.

So it's more of like null doesn't exist in the eyes of a Custom Attribute, instead it should just get disconnected. The null is a value in the eyes of an element (f.e. Custom Element), so that it knows an attribute is not connected (the custom attributes that this is the case when disconnectedCallback is called).

In my use cases, I found it useful to know what the last value was during disconnected (and I can automatically infer the DOM's is null due to disconnectedCallback, though in practice I never need the null value, because I already know when my custom attribute is disconnected and can react to that).

else if(newVal == null) {
if(inst.disconnectedCallback) {
inst.disconnectedCallback();
}
Expand Down