Friday, May 26, 2017

xml4jQuery 1.1.0 released

Proud of it. Finally passed a full set of tests on all features I had in mind:

  • event handling 
  • call chain results propagated into callbacks 
  • Promise support for single run and $then() for recurrent call chain invocation 
  • error handling matching the Promise behavior 

$(".toFill")    .html("Click here")
                .xmlTransform( 'test/test.xml', 'test/test.xsl')
                .prepend('Still clickable <hr/>');
 Also not so visible:

  • moved tests to ES6, they shortened at least twice 
  • made release build script to match CDN and NPM deployments, before it was a manual process 
  • started to use for project documentation 
For next release:

  • IE tests compatibility via AMD loader shim to load ES6 in IE on fly
  • $then() to accept other async chain 
Somewhere in future
  • refactor sources to ES6, target compiler to ES6, 
  • auto-transpiler shim for IE reference implementation

Thursday, May 18, 2017

JS in browser tricks

Convert arguments, NodeList, attributes to normal JS array

Little notes for myself el=>console.log(el) ) // arguments to normal JS array
Object.keys({a:0}) // keys to array

[... this.attributes].filter( el=>!'data-') ).forEach( el=> console.log(, el.value) ) // DomElement attributes (NamedNodeMap) to array es6
Array.from(this.attributes).filter( el=>!'data-') ) // -||- es5 + shim 'input[type=checkbox]' ), item => item.checked = true ); // es5

// ES6 

let divsArray = [...document.querySelectorAll('div')]; // Convert NodeList to Array

let argsArray = [...arguments]; // Convert Arguments to Array
For IE and legacy use polyfills from core-js or babel-polyfill