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

cache-component <-> nanocomponent [email protected] #38

Merged
merged 127 commits into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
fca222c
.
yoshuawuyts Oct 3, 2016
2a7787d
fix(docs): faq
yoshuawuyts Oct 3, 2016
5895050
Continued implementation based on @jekrb's code (#4)
roobie Oct 14, 2016
5ef3ebf
Implement cache (#5)
yoshuawuyts Oct 14, 2016
d20b240
fix(travis): bump versions
yoshuawuyts Oct 14, 2016
a167ace
1.0.1
yoshuawuyts Oct 14, 2016
a35735f
feat(widget): init (#6)
yoshuawuyts Oct 14, 2016
e64c6b6
1.1.0
yoshuawuyts Oct 14, 2016
4e85ab3
fix(widget): fix argument passing (#7)
reminyborg Oct 15, 2016
bdb72dc
1.1.1
yoshuawuyts Oct 15, 2016
8088406
feat(build): add UMD build (#13)
xz64 Nov 27, 2016
c986b3e
1.1.2
yoshuawuyts Nov 27, 2016
eb401be
1.1.3
yoshuawuyts Nov 27, 2016
3ebed1e
chore(package): update envify to version 4.0.0 (#14)
greenkeeperio-bot Nov 30, 2016
fd4c3ab
feat(index): update API (#18)
yoshuawuyts Dec 1, 2016
04af949
2.0.0
yoshuawuyts Dec 1, 2016
46e070a
s/const/var
yoshuawuyts Jan 4, 2017
e5c5d74
2.0.1
yoshuawuyts Jan 4, 2017
f4e25a2
Initial commit
bcomnes Apr 10, 2017
03c84d0
initial commit
bcomnes Apr 10, 2017
79a7b84
add assertions
bcomnes Apr 10, 2017
0c5e092
Merge tag 'v2.0.1'
bcomnes Apr 11, 2017
e478c43
update readme
bcomnes Apr 11, 2017
49ce076
improve docs on _update method
bcomnes Apr 11, 2017
f9ab57f
fix tests
bcomnes Apr 11, 2017
c880eab
a few tweaks
bcomnes Apr 11, 2017
560e7d3
update package.json
bcomnes Apr 11, 2017
90bc1bf
3.0.0-0
bcomnes Apr 11, 2017
ba01e58
update _update function signature
bcomnes Apr 11, 2017
719f9a9
3.0.0-1
bcomnes Apr 11, 2017
e50174a
handle DOM removal
Apr 11, 2017
09c0697
Merge pull request #3 from blahah/patch-1
bcomnes Apr 11, 2017
d0b505b
3.0.0-2
bcomnes Apr 11, 2017
9a50cb0
Restore proxied mutated elements (solves #4)
Apr 12, 2017
9131106
Merge pull request #5 from hypermodules/proxy-mutants
bcomnes Apr 12, 2017
7bdff89
3.0.0-3
bcomnes Apr 12, 2017
2b63c96
update readme
bcomnes Apr 12, 2017
9e63d91
putting a bow on it
bcomnes Apr 12, 2017
bfe4bd6
cache proxy
bcomnes Apr 16, 2017
5c592c5
use direct proxy logic
bcomnes Apr 16, 2017
6b494a1
only capture dom references once
bcomnes Apr 17, 2017
5dab9b1
prepare for 3.0.0 release
bcomnes Apr 17, 2017
3bb9ccb
v3.0.0
bcomnes Apr 17, 2017
4c33edc
remove old publishing stuff
bcomnes Apr 17, 2017
7267eaa
fix readme typos
ungoldman Apr 19, 2017
5b02280
fix another typo
ungoldman Apr 19, 2017
841f881
Merge pull request #6 from hypermodules/typos
bcomnes Apr 19, 2017
e273004
implement dom loading lifecycles
bcomnes Apr 21, 2017
84080ea
handle morphing internally
bcomnes Apr 21, 2017
2657327
Merge remote-tracking branch 'origin/master'
bcomnes Apr 21, 2017
6378626
v4.0.0
bcomnes Apr 21, 2017
a764b85
fix weird tests that don't really test
bcomnes Apr 21, 2017
57524f4
update readme
bcomnes Apr 21, 2017
8a4909b
fix instance morph clobbering
bcomnes Apr 22, 2017
bb60253
fix one last thing
bcomnes Apr 22, 2017
46edb06
also id rendered elements
bcomnes Apr 22, 2017
b558ffe
Merge pull request #9 from hypermodules/instance-clobber
bcomnes Apr 22, 2017
6c9e9a6
v4.0.1
bcomnes Apr 22, 2017
b3581a0
Update README.md
bcomnes Apr 23, 2017
336acac
Update README.md
bcomnes May 2, 2017
df7cf15
run unload methods before clearing internal refs
bcomnes May 6, 2017
b63ab9d
v4.0.2
bcomnes May 6, 2017
8253dc8
update lock file
bcomnes May 6, 2017
894ccef
Experiment to remove on-load
bcomnes May 11, 2017
53a2a78
Use nanomorph again and add ._didUpdate
bcomnes May 17, 2017
1843d35
Update changelog
bcomnes May 17, 2017
ac49ec4
Merge pull request #12 from hypermodules/5.0.0-beta
bcomnes May 17, 2017
cc39c12
v5.0.0-1
bcomnes May 17, 2017
08ad17f
chore(package): update bel to version 5.0.0
greenkeeper[bot] May 19, 2017
9fa6538
fix(package): update nanomorph to version 5.0.0
greenkeeper[bot] May 22, 2017
97a0285
Fix spelling in Error thrown by default '_render' method
joshgillies May 31, 2017
4e26163
Merge pull request #17 from joshgillies/fix-error-message
bcomnes Jun 1, 2017
8ca6374
Merge pull request #15 from hypermodules/greenkeeper/bel-5.0.0
bcomnes Jun 19, 2017
c0331ea
Merge pull request #16 from hypermodules/greenkeeper/nanomorph-5.0.0
bcomnes Jun 19, 2017
d7f537f
Update changelog about bel. Prep for 5.0.0
bcomnes Jul 2, 2017
a11fec7
v5.0.0
bcomnes Jul 2, 2017
040ea22
Merge branch 'master' into 6
bcomnes Jul 2, 2017
04209bc
update nanomorph again
bcomnes Jul 2, 2017
d8e7d6a
Reset proxy after dom-removal
bcomnes Jul 3, 2017
ba01439
v5.0.1
bcomnes Jul 3, 2017
5e308df
spelling in CHANGELOG
bcomnes Jul 3, 2017
59c0ff5
Merge commit '04209bca60676f9e6c1256373cf0ebe0b8e9f052'
bcomnes Jul 3, 2017
0209023
v5.1.0
bcomnes Jul 3, 2017
5bedd63
Add more lifecycle hooks
bcomnes Jul 5, 2017
0ccd8e3
v5.2.0
bcomnes Jul 5, 2017
ef1c193
Add optional on-load lifecycles
bcomnes Jul 7, 2017
b283045
rename this._element to this.element
bcomnes Jul 7, 2017
1ab8c92
Remove noop
bcomnes Jul 7, 2017
1b887c4
Add assertions
bcomnes Jul 8, 2017
ed4825e
More tweaks
bcomnes Jul 8, 2017
39d98cf
a few edits on the README
bcomnes Jul 8, 2017
bc23b17
Update README.md
bcomnes Jul 8, 2017
e7517cd
Update README.md
bcomnes Jul 8, 2017
bc41218
Minor var tweak
bcomnes Jul 8, 2017
a817e92
More renaming
bcomnes Jul 11, 2017
1a04354
Merge remote-tracking branch 'origin/optional-onload' into optional-o…
bcomnes Jul 11, 2017
7bb3d9e
Fix server side tests
bcomnes Jul 12, 2017
3549ce2
Add examples to README
bcomnes Jul 12, 2017
3105685
Update reademe
bcomnes Jul 12, 2017
6ebd95a
bel free example
bcomnes Jul 12, 2017
b0f7ab9
add unload example
bcomnes Jul 12, 2017
4493084
reorder
bcomnes Jul 12, 2017
69fe708
remove link
bcomnes Jul 12, 2017
b794ded
rework docs
yoshuawuyts Jul 12, 2017
b47b797
Merge pull request #19 from hypermodules/rework-docs
bcomnes Jul 13, 2017
15ea2dc
Add other lifecycle module references
bcomnes Jul 13, 2017
b3a2e04
Merge branch 'optional-onload' into nc-master
bcomnes Jul 13, 2017
fd166cb
Added a few links back to the readme
bcomnes Jul 13, 2017
a3dd190
darnit dont yarn it
bcomnes Jul 13, 2017
8cd93f2
Add bankai
bcomnes Jul 13, 2017
d9e89d7
Progress on leaflet example
bcomnes Jul 15, 2017
e1bb2e4
Fix bug
bcomnes Jul 15, 2017
3ad448c
Update leaflet example
bcomnes Jul 15, 2017
ce54f4f
Finish updates on leaflet
bcomnes Jul 15, 2017
cfb809f
Update changelog and a few other tweaks
bcomnes Jul 16, 2017
b657b81
Finish changelog for cache-component
bcomnes Jul 16, 2017
001e5c2
Update breaking change note
bcomnes Jul 16, 2017
10b27dc
Minor wording tweak
bcomnes Jul 16, 2017
2c9bcd6
Update README and CHANGELOG some more
bcomnes Jul 16, 2017
7b19b7f
Added nanocomponent5 -> 6 guide
bcomnes Jul 17, 2017
4c17398
Fix syntax consistency in CHANGELOG
bcomnes Jul 17, 2017
fd48cab
One more tweak
bcomnes Jul 17, 2017
63df597
I don’t like the periods in fact.
bcomnes Jul 17, 2017
2e77162
Fix word salad
bcomnes Jul 17, 2017
2e84290
Less periods again
bcomnes Jul 17, 2017
041a93e
Add link
bcomnes Jul 17, 2017
1a889b9
v6.0.0-0
bcomnes Jul 17, 2017
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
15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
dist: trusty
language: node_js
node_js:
- "0.12"
- "4"
- 'node'
sudo: false
language: node_js
script: "npm run test:cov"
after_script: "npm i -g codecov.io && cat ./coverage/lcov.info | codecov"
cache:
directories:
- ~/.npm
install:
- npm i
script:
- npm test
128 changes: 128 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# nanocomponent Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## 6.0.0 - DATE HERE

🎉 nanocomponent and [cache-component][cc] are merged into one module: `[email protected]` 🎉.

Be sure to read the README so that you get an understanding of the new API, but here is a quick summary of what has changed from the perspective of both modules:

### Changes since `cache-component@5`

`nanocomponent@6` is mostly the same as `cache-component@5` except for the following:

- **Breaking**: The `_element` [getter][getter] is renamed to `element`.
- **Breaking**: `_willMount` is renamed to `_willRender` because DOM mounting can't be guaranteed from the perspective of a component.
- **Breaking**: `_didMount` is removed. Consider using `_load` instead now. If you want this on-load free hook still, you can just call `window.requestAnimationFrame` from `_willRender`.
- **Breaking**: `_willUpdate` is removed. Anything you can do in `_willUpdate` you can just move to `_update`.
- **Breaking**: `_update` should always be implemented. Instead of the old default shallow compare, not implementing `_update` throws. You can `require('nanocomponent/compare')` to implement the shallow compare if you want that still. See below.
- **Changed**: `_didUpdate()` now receives an element argument `el` e.g. `_didUpdate(el)`. This makes it's argument signature consistent with the other life-cycle methods.
- **Added**: Added [on-load][ol] hooks `_load` and `_unload`. [on-load][ol] listeners only get added when one or both of the hooks are implemented on a component making the mutation observers optional.


#### `cache-component@5` to `nanocomponent@6` upgrade guide:

- No changes nessisary to `_render`
- You must implement `_update` now. Here is an example of doing shallow compare on components that didn't implement their own update function previously:

```js
var html = require('choo/html')
var Component = require('nanocomponent')
var compare = require('nanocomponent/compare')

class Meta extends Component {
constructor () {
super()

this._title = null
this._artist = null
this._album = null
}

_render (title, artist, album) {
this._title = title || '--'
this._artist = artist || '--'
this._album = album || '--'

return html`
<div>
<p>${title}</p>
<p>
${artist} - ${album}
</p>
</div>
`
}

// Implement this to recreate cache-component@5
// behavior when _update was not implemented
_update () {
return compare(arguments, this._args)
}
}

```

- Rename components with `_willMount` to `_willRender`
- Move any `_didMount` implementations into `_load` or a `window.requestAnmimationFrame` inside of `_willRender`.
- Move any `_willUpdate` implementations into `_update`.
- `_didUpdate` remains the same.
- Take advantage of `_load` and `_unload` for DOM insertion aware node interactions 🙌

### Changes since nanocomponent@5

`nanocomponent@6` has some subtle but important differences from `nanocompnent@5`. Be sure to read the README and check out the examples to get an understanding of the new API.

- **Breaking**: The `_element` property is removed. A [getter][getter] called `element` is now used instead. Since this is now a read-only getter, you must not assign anything to this property or else bad things will happen. The `element` getter returns the component's DOM node if mounted in the page, and `undefined` otherwise. You are allowed to mutate that DOM node by hand however. Just don't reassign the property on the component instance.
- **Changed**: `render` can now handle being removed and re-rendered into the DOM. It can also handle rendering two instances of components in two different views over each other.
- **Breaking**: `_render` must now return a DOM node always. In earlier versions you could get away with not returning from `_render` and assigning nodes to `_element`. No longer! Also, you should move your DOM mutations into `_update`.
- **Changed**: Update still works the same way: return true to run `_render` or return false to skip a call to `_render` when `render` is called. If you decide to mutate `element` "by hand" on updates, do that here (rather than conditional paths inside `_render`).
- **Changed**: `_load` and `_unload` have always been optional, but now the mutation observers are only added if at least one of these methods are implemented prior to component instantiation.
- **Added**: `_willRender` lifecycle hook. Its similar to `_load` but runs before mounting.
- **Added**: `_didUpdate` runs after `_update` returns true and the results of `_render` is mutated over the mounted component. Useful for adjusting scroll position.
- **Fixed**: More robust unmount and remounting behavior.

#### `nanocomponent@5` to `nanocomponent@6` upgrade guide:

- Read through the new leaflet example to get an idea of the differences between the old and new API. 🗺
- Move any DOM mutation code from `_render` into `_update`.
- Ensure `_render` returns a DOM node always. (You will get warnings if you don't and it probably won't work)
- Consider moving any `_load` actions into `_willRender` if they don't depend on the newly rendered node being mounted in a DOM tree yet.
- Take advantage of `_didUpdate` allowing you to interact with your component after `_render` is called on mounted components 🙌

## 5.2.0
* Added more lifecycle hooks: `_willMount`, `_didMount`, `_willUpdate` in addition to `_didUpdate`.

## 5.1.0
* Update [nanomorph](http://ghub.io/nanomorph) to `^5.1.2`. This adds the new child-reordering algorithm so we get a minor version bump. Keep an eye out for weird ness and report broken corner cases 🙏

## 5.0.1
* Fix proxy leak by resetting proxy node ID after DOM removal is detected.

## 5.0.0
* Update [bel](http://ghub.io/bel) to ^5.0.0

## 5.0.0-1 - 2017-05-16
* Beta release! Please let me know if there is anything wrong with this!
* **Breaking**: Remove `on-load` and use a new DOM ID based DOM tracking system. Requires ES5 support for getters.
* **Breaking**: Remove `_load` and `_unload` methods. You have to wrap instances of `cache-component` with `on-load` on your own now.
* **Added**: Add `_didUpdate` hook so you can call DOM methods after the component updates. Handy for updating a scroll position.

## 4.0.2 - 2017-05-05
* Run _unload before we clear internal references, allowing you to clean up event listeners on `this._element` and anything else you want to do.

## 4.0.1 - 2017-04-10
* Fix instance clobbering bug. This bug showed up when you had two instances of the same component morphing over each other. This would cause the real DOM reference to get lost between the internal _element references of the two instances. The work around was the introduction of ccId which is a unique ID to prevent this.

## 4.0.0 - 2017-04-10
* use [on-load](https://github.com/shama/on-load) to invalidate `this._element`. Fixes component rendering when they get completely removed from the DOM.
* added `_load` and `_unload` methods to allow you to run code when the DOM is mounted and unmounted.
* handle morphing internally, and ALWAYSE return a proxy node. There is no other way.

## 3.0.0 - 2017-04-10
* initial release

[ol]: https://github.com/shama/on-load
[cc]: https://github.com/hypermodules/cache-component
[getter]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get
Loading