Skip to content

Releases: fpereiro/gotoB

2.3.2

08 May 20:08

Choose a tag to compare

  • Fix a very rare bug that happens when trampling a reactive view that has a non-element DOM element (such as a text node) just after it.

Special thanks to Browserstack for still letting me test this arcana in IE6!

2.3.1

05 Sep 19:55

Choose a tag to compare

  • Add more examples: tictactoe, flux challenge, github profiles

2.3.0

27 Feb 12:30

Choose a tag to compare

  • 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 your check functions return true if they succeed, or monkey-patch c.test copying the function at v3.1.0 version of c.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.ev as a no-op argument - this is useful for conditionals of the form B.ev (condition ? ['verb', 'path'] : []).
  • Bugfix: do not recycle elements that had an onclick handler and will have an href property, since in rare cases that will lead to the element being recycled also being clicked and that href being followed by the browser.

2.2.0

16 Aug 08:06

Choose a tag to compare

  • 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.eventlog style.
  • Improve error messages: show less output but with more relevant information.
  • Add mute responders that don't add a change event.
  • When calling a rem event on X.Y, a change event is called on X.Y, not on X as before. This avoids a change on X.Y generating a change on X and then an unwanted change on X.Z. Note: if you pass multiple arguments to rem, that call will perform multiple calls to change, one per path.
  • Finish 7 GUIs cells!

2.1.1

07 Jul 19:00

Choose a tag to compare

  • B.eventlog now takes an optional search parameter.
  • Improvements to error reporting when passing an invalid lith to B.view.

2.1.0

21 Jun 19:07

Choose a tag to compare

  • Bugfix: properly redraw views that contain a style with contents that are a litc.
  • Bugfix: the args to 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 redraw event: instead of diffLength, we now have an object diff with length and edits, 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

14 Jun 19:06

Choose a tag to compare

  • Readme: Tutorial moved to an appendix, since it's more a conceptual introduction to webapps than about gotoB.

2.0.0

03 Jun 21:01

Choose a tag to compare

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.
  • Major changes in dependencies:
    • dale: dale.obj and dale.times return false instead of undefined when receiving invalid inputs; dale.obj now also checks that arrays of length 2 are returned from the iterating function.
    • lith: lith.css.style (formerly lith.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.y will now get triggered only by an event with path State.x.y. Wildcards and regexes will still work. To create responders with different matching, use the match property of the responder.
      • B.call now returns event ids.
      • x.from is now a string with an event or responder id.
      • B.log now holds a history of all the events called and of all responders matched. B.log is merely a shortcut to r.log, the logging object available as of recalc v4.0.0.
      • If you pass an id to B.respond, it cannot be an R or E followed by digits. Event and responder ids are now non-random and have those shapes if generated by recalc.
  • Error reporting
    • B.eventlog doesn't exist anymore. It has been superseded by B.log (an object for holding all the information of called events) and B.eventlog (a function for displaying the data in B.log) for debugging or performance improvement.
    • An event with verb error is now called by all gotoB functions that encounter an error. An event responder on events with verb error
    • 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) and rem (no keys, non-existing keys or undefined target).
    • change responders now receive currentValue and previousValue as 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 a change event.
  • 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 that B.ev now returns a stringified event handler, instead of an entire attributes object.
    • B.ev now calls an ev event with the event type as its path. It then passes the event id to the other invocations to B.call.
    • You can now pass no arguments to B.ev.
    • Remove support for args or rawArgs keys. 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.evh to collect further data about the DOM element which received the event, to be passed to the ev event; by encapsulating this into a function, the event handler is cleaner and easier to read from the developer tools.
  • 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.mrespond to invoke B.respond multiple times, passing an array of arrays of arguments.
  • B.view
    • x is not passed anymore to B.view.
    • Can now pass multiple paths instead of just one. If a change event 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 x as 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 options object is completely removed:
      • To specify a tag, you now must return it from the view function directly. Same goes for attrs, 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 when B.view updates the DOM. To replace these, you can specify responders with verb change and 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.
    • The listen property is completely removed. You can specify responders instead outside of the invocation to B.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.y will now be updated by a change on State.x, but only if its value changes. Before, it would only happen if State.x.y (or a longer path starting with that, like State.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.prod is falsy, an error will be reported. All further redrawings will not be performed.
    • Whenever a redraw happens, an event with verb redraw will be fired, including performance information. This supersedes B.perflogs, which has been completely removed.
    • Support for LITERAL pseudo-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 renamed path.
    • 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 ... > -1
    • log -> clog
  • Internals:
    • B.applyDiff taken out of B.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

16 Jul 11:12

Choose a tag to compare

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

29 Mar 12:58

Choose a tag to compare

This release includes fixes and small improvements to v1, in preparation for the release of an upcoming major version:

  • Bugfix: opaque elements now can be empty, contain text or contain multiple HTML elements. The previous code assumed that opaque elements only could contain a single HTML element as its contents.
  • Bugfix: fix redraw logic for opaque in the case there are multiple deletions in a row in the diff.
  • If B.perflogs is set to true, 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 !