Releases: fpereiro/gotoB
Releases · fpereiro/gotoB
2.3.2
2.3.1
2.3.0
- Update cocholate v3.1.0 -> v4.0.0, uglifyjs v3.16.3 -> v3.17.4
- If you're using
c.test, there's a breaking change - either make yourcheckfunctions returntrueif they succeed, or monkey-patchc.testcopying the function at v3.1.0 version ofc.test(available at https://github.com/fpereiro/cocholate/blob/d1e57a3303f7bc7cd032ed63da91d4f250efa31e/cocholate.js#L306) on a script below the inclusion of gotoB. - Improve examples.
- You can now pass an empty array to
B.evas a no-op argument - this is useful for conditionals of the formB.ev (condition ? ['verb', 'path'] : []). - Bugfix: do not recycle elements that had an
onclickhandler and will have anhrefproperty, since in rare cases that will lead to the element being recycled also being clicked and thathrefbeing followed by the browser.
2.2.0
- Update teishi v5.0.3 -> v5.1.0, lith v6.0.6 -> v6.0.7, recalc v5.1.1 -> v5.1.2, cocholate v3.0.3 -> v3.1.0, uglifyjs v3.13.10 -> v3.16.3
- ~20% perf improvement when generating liths in non-prod mode (from lith update).
- Improve
B.eventlogstyle. - Improve error messages: show less output but with more relevant information.
- Add mute responders that don't add a change event.
- When calling a
remevent onX.Y, achangeevent is called onX.Y, not onXas before. This avoids a change onX.Ygenerating achangeonXand then an unwantedchangeonX.Z. Note: if you pass multiple arguments torem, that call will perform multiple calls tochange, one per path. - Finish 7 GUIs cells!
2.1.1
2.1.0
- Bugfix: properly redraw views that contain a
stylewith contents that are a litc. - Bugfix: the
argsto each log entry are now copied, so its values are preserved at the moment of when the logging took place. This avoids showing incorrect data in the logging of data events (the fix comes from the upgrade to recalc). - Change the data shown by the
redrawevent: instead ofdiffLength, we now have an objectdiffwithlengthandedits, to give more info about which redraws require a lot of edits. - Small improvements to readme.
- Dependency upgrades: recalc 5.1.0 -> 5.1.1, uglifyjs 3.10.8 -> 3.13.9
2.0.1
2.0.0
A new major version of gotoB, two years in the making!
This is something between a major change in version and a complete rewrite. The changes from v1 are extensive. The core concepts remain the same, but everything has changed. If you have an app written in gotoB v1 and you need help to migrate to v2, please contact me or open an issue.
Here's the changelog:
- Dependency upgrades: dale 4.3.3 -> 6.0.2, teishi 3.13.2 -> 5.0.3, lith 4.5.3 -> 6.0.6, recalc 3.8.2 -> 5.0.4, cocholate 1.6.6 -> 3.0.3, uglifyjs 3.10.0 -> 3.13.0
- Function renamings (you must rename them in your code or create an alias (
OLDFUNCTIONNAME = NEWFUNCTIONNAME):- dale:
dale.do->dale.go - teishi:
teishi.t->teishi.type,teishi.l->teishi.clog,teishi.c->teishi.copy,teishi.s->teishi.str,teishi.p->teishi.parse - lith:
lith.style->lith.css.style - recalc:
B.do->B.call,B.routes->B.responders,B.listen->B.respond.
- dale:
- Major changes in dependencies:
- dale:
dale.objanddale.timesreturnfalseinstead ofundefinedwhen receiving invalid inputs;dale.objnow also checks that arrays of length 2 are returned from the iteratingfunction. - lith:
lith.css.style(formerlylith.style) no longer accepts HTML attributes and it returns a string instead of an object:lith.style ({class: 'a'}, {height: 1})->{class: 'a', style: lith.css.style ({height: 1})}. - recalc:
- Change in recalc's default matching: a responder on path
State.x.ywill now get triggered only by an event with pathState.x.y. Wildcards and regexes will still work. To create responders with different matching, use thematchproperty of the responder. B.callnow returns event ids.x.fromis now a string with an event or responder id.B.lognow holds a history of all the events called and of all responders matched.B.logis merely a shortcut tor.log, the logging object available as of recalc v4.0.0.- If you pass an id to
B.respond, it cannot be anRorEfollowed by digits. Event and responder ids are now non-random and have those shapes if generated by recalc.
- Change in recalc's default matching: a responder on path
- dale:
- Error reporting
B.eventlogdoesn't exist anymore. It has been superseded byB.log(an object for holding all the information of called events) andB.eventlog(a function for displaying the data inB.log) for debugging or performance improvement.- An event with verb
erroris now called by all gotoB functions that encounter an error. An event responder on events with verberror - Error reporting is now done on the body of the document itself, as a popup with error information. The previous practice of logging errors to the console made them silent, unless you ran through the entire app while looking at what was printed by the console. By putting them in the forefront, we're following the principle of auto-activation which is at the core of the ustack.
- Data functions
B.set:- Can now receive optional context as its first argument.
- Remove overwriteParent logic that required an extra argument when overwriting a path element with a longer path.
- Bugfix: don't assume that the store is of the appropriate type.
B.add:- Can now receive optional context as its first argument.
- Performance improvement: remove type validation when B.prod is enabled.
- Implicitly remove overwriteParent logic when target is undefined but path is incompatible with the current values on the store.
B.rem:- Can now receive optional context as its first argument.
- If removing something from a target that is
undefined, we now consider it as a no-op instead of an error. Removing something from a simple target is still an error.
- Data events:
- Performance improvement: Don't trigger change on no-ops on
add(no extra arguments) andrem(no keys, non-existing keys or undefined target). changeresponders now receivecurrentValueandpreviousValueas arguments, for convenience when writing the responder functions. If you trigger a change manually and your responder functions depend on these arguments, you must pass them manually. gotoB's internals don't rely on this, so you're not forced to pass these extra parameters when triggering achangeevent.
- Performance improvement: Don't trigger change on no-ops on
B.ev:- Completely new usage: what before was written
B.ev ({class: 'foo'}, ['onclick', 'verb', 'path'])is now written as{class: 'foo', onclick: B.ev ('verb', 'path')}. For multiple events:B.ev ({class: 'foo'}, [['onclick', 'verb', 'path'], ['onclick', 'verb2', 'path2']])->{class: 'foo', onclick: B.ev (['verb', 'path'], ['verb2', 'path2'])}. Notice thatB.evnow returns a stringified event handler, instead of an entire attributes object. B.evnow calls anevevent with the event type as its path. It then passes the event id to the other invocations toB.call.- You can now pass no arguments to
B.ev. - Remove support for
argsorrawArgskeys. Instead, if you want a certain argument to be passed without it being stringified, pass it in the form{raw: STRING}. - Use of a helper function
B.evhto collect further data about the DOM element which received the event, to be passed to theevevent; by encapsulating this into a function, the event handler is cleaner and easier to read from the developer tools.
- Completely new usage: what before was written
B.mount:- Better validation, so that you cannot pass #abc>... or #bcd+ or ~ (underlying getElementById will not return an element)
- Now receives a function that returns a lith or lithbag, instead of a lith or lithbag.
B.unmount:- Better validation, so that you cannot pass #abc>... or #bcd+ or ~ (underlying getElementById will not return an element)
- Now eliminates all the contents of the target, instead of just the reactive elements.
- Add
B.mrespondto invokeB.respondmultiple times, passing an array of arrays of arguments. B.viewxis not passed anymore toB.view.- Can now pass multiple paths instead of just one. If a
changeevent affects more than one of them, the leftmost matched path will trigger the redraw. - View function:
- The function must now return a lith (not a lithbag). This element is the container element.
- The function no longer receives
xas an argument, since it is not supposed to call events (it should be pure). - The function now receives n arguments, one per path passed to
B.view.
- The
optionsobject is completely removed:- To specify a
tag, you now must return it from the view function directly. Same goes forattrs, they can directly be placed within the returned element. respond: responders no longer have the lifecycle of a view, but rather are permanently active until you decide to remove them.ondraw/onforget: no events or responders are fired/matched whenB.viewupdates the DOM. To replace these, you can specify responders with verbchangeand the same path(s) as the desired view, and assign a low negative priority (e.g: -1000), which will ensure that the responder will be matched after the changes to the DOM are applied.
- To specify a
- The
listenproperty is completely removed. You can specify responders instead outside of the invocation toB.view. The lifecycle of the responders is now completely decoupled from that of the views. - Change in default matching: an element depending on path
State.x.ywill now be updated by a change onState.x, but only if its value changes. Before, it would only happen ifState.x.y(or a longer path starting with that, likeState.x.y.z) was changed. This means that some views will now be redrawn that weren't redrawn before. - If attempting to redraw a dangling view (a view that is not in the DOM) and
B.prodis falsy, an error will be reported. All further redrawings will not be performed. - Whenever a redraw happens, an event with verb
redrawwill be fired, including performance information. This supersedesB.perflogs, which has been completely removed. - Support for
LITERALpseudo-tags. If just text, can be added anywhere; if they contain DOM elements, they must be inside an opaque element. - The
path-вproperty has been renamedpath. - Performance improvements: if an element is already inside the right parent in the right position, it's not removed from the DOM.
- Bugfix: fix corner case where there's
id="B...as text somewhere, which was interpreted as a nested reactive element.
- Internal stylistic changes:
indexOf ... !== -1->indexOf ... > -1log->clog
- Internals:
B.applyDifftaken out ofB.redraw.- Renamings in the variables used by
B.redraw:B.count->B.internal.count.B.trample->B.internal.timeout.B.resolvequeue->B.internal.queue.B.resolving->B.internal.resolving.
- Empty queue if all reactive elements in it are already deleted by the time they can be updated.
- Performance: the diff algorithm has been rewritten and should be 15-25% faster on modern browsers; the view generation and DOM manipulation functions are 50-100% faster. Notably, a significant amount of unnecessary DOM operations are now avoided.
1.2.5
This release includes fixes and small improvements to v1, in preparation for the release of an upcoming major version:
- Bugfix,
B.rem: if an array with keys is passed as the second argument, it is copied so that the original is not modified. - Bugfix, build script: total lines of code were overestimated by 6.
- Fix & update TodoMVC CSS (thanks @akkartik for pointing this out!)
- Internals (B.applyDiff):
- Bugfix: when inserting kept or added elements, the diff element index was used to insert the element into its parent, instead of the desired position of the element.
- Small performance improvement.
- Update dependency:
uglify-js v3.4.9 -> v3.10.0
1.2.4
This release includes fixes and small improvements to v1, in preparation for the release of an upcoming major version:
- Bugfix:
opaqueelements now can be empty, contain text or contain multiple HTML elements. The previous code assumed thatopaqueelements only could contain a single HTML element as its contents. - Bugfix: fix redraw logic for
opaquein the case there are multiple deletions in a row in the diff. - If
B.perflogsis set totrue, gotoB will print how much time it takes to redraw a view, printing an object of the form:{start: TIMESTAMP, draw: <milliseconds taken by the execution of the view function>, diff: <milliseconds taken by the computation of the diff, including the flattening of the views> and total: <total time taken, including the overhead of the redraw function>}. This logic will be overriden and improved in v2. - Improved error message in case of a redraw error.
With thanks to @yumaikas !