2017-05-26

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")
                .$on('click')
                .html('Loading...')
                .sleep(1000)
                .xmlTransform( 'test/test.xml', 'test/test.xsl')
                .toggleClass('clickable')
                .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 ApiFusion.com 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

  xml4jQuery.com

2017-05-18

JS in browser tricks

Convert arguments, NodeList, attributes to normal JS array

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


[... this.attributes].filter( el=>!el.name.indexOf('data-') ).forEach( el=> console.log(el.name, el.value) ) // DomElement attributes (NamedNodeMap) to array es6
Array.from(this.attributes).filter( el=>!el.name.indexOf('data-') ) // -||- es5 + shim
Array.prototype.forEach.call(document.querySelectorAll( '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