Update
This snippet is now improved and officially an npm module called dom-handler
| // ES5 dirty perf oriented tweet size | |
| var O=function(O,s){s=O.setPrototypeOf||function(o,p){o.__proto__=p;return o};return function(p,o){return o?s(o,p):p||s({},p)}}(Object); | |
| // ES5 dirty performance way | |
| var O = function(Object){ | |
| var | |
| create = Object.create, | |
| set = Object.setPrototypeOf || function(o, p) { | |
| o.__proto__ = p; | |
| return o; |
Update
This snippet is now improved and officially an npm module called dom-handler
All code assumes define strict properties in included upfront.
However, being the proposal fullyt backward compatible, you can tests these snipets by copy and paste but no type will be guarded.
function Point2D(x, y) {
this.x = x;
this.y = y;
}Generates a Markdown friendly output similar to the one showed here.
(function show(object, name, all) {
var f, k, later = [], list = ['### ' + name, '```javascript'];
all.push(object);
Object.getOwnPropertyNames(object).forEach(function(name) {
list.push(name);
if (/^[A-Z]/.test(name) && object[name] instanceof Object) {
later.push([object, name]);| function createEmitter() { | |
| // not ideal when many simple emitters are needed | |
| // returns object similar to node.js EventEmitter API | |
| // not compatible with DOM nodes, only JS controllers | |
| var | |
| // on, off, emit as immutable and non enumerable | |
| // all methods returns the implicitly bound emitter | |
| emitter = Object.create(null, { | |
| on: {value: function (type, handler) { | |
| var tmp = get(type); |
When the getOwnPropertyDescriptors function is called, the following steps are taken:
| 'getOwnPropertyDescriptors' in Object || ( | |
| Object.getOwnPropertyDescriptors = function (Object) { | |
| var | |
| gOPD = Object.getOwnPropertyDescriptor, | |
| gOPN = Object.getOwnPropertyNames, | |
| gOPS = Object.getOwnPropertySymbols, | |
| gNS = gOPS ? function (object) { | |
| return gOPN(object).concat(gOPS(object)); | |
| } : | |
| gOPN, |
Multiple scripts and multiple libraries have usually a common need of the W3C Web Storage, either the local or the session one.
However, it is extremely easy and very hard to prevent a not so infrequent storage.clear() call, able to remove any sort of data and for any kind of lbirary in the same realm.
This proposal aim is to harmonize multiple libraries preserving same interface but enriching the constructor.
Please note that current WebIDL is almost identical to the one already recommended by W3C.