Re: Everyone Closer To DOM Level 4

A humble log post including other things I consider cool these days:
http://webreflection.blogspot.com/2013/10/web-developing-has-never-been-so.html

It's about being able today to finally rely in a wide variety of features
made possibly compatible across 99.9% of browsers market share, including
IE8 :-)

Now considering to implement firstElementChild and friends too or, at
least, children.

Surprisingly, nobody filed a bug against IE8 (the real one) ... although I
have the feeling numbers behind this browser are rather blown by developers
testing against it instead of real usage :D

Just kidding, I have a very old machine running that monstrosity natively,
the only way to be sure things won't break.

The most annoying part about IE8 is the bug with function expression VS
declaration where inline expression are not easy to be removed.

window.addEventListener('load', function load() {
  this.removeEventListener('load', load); // won't work
  this.removeEventListener('load', arguments.callee); // the only way
  // the other would be to address load in the outer scope through a
variable
});

Things are a bit scarier than innocent `arguments.callee` when it comes to
double accidentally fired events ..

var i = 0;
window.addEventListener('load', function onload() {
  alert(++i);
});

the onload will be addressed as `window.onload` too so that function will
be inevitably fired twice in IE8 in such very specific form.

To avoid all these headaches I've extended to the DOM my event-driven
augmented environment called eddy.js so that anyone can simply do

window.once('load', function () {
  // no need to use a named function expression
  // since there's no need to remove it in here
  // this will be called once regardless
});

This is probably more than what I've written in the blog post I've
mentioned.

Best Regards
















On Sun, Oct 6, 2013 at 6:12 AM, Brian Kardell <bkardell@gmail.com> wrote:

> andrea,
>
> sorry for not responding sooner, i was traveling and am way behind.  Have
> you pushed this out anywhere or blogged about it or anything? filed any
> bugs? ttwf submissions? i will look at this some more tomorrow but on first
> pass looks interesting.
> On Oct 3, 2013 9:32 PM, "Andrea Giammarchi" <andrea.giammarchi@gmail.com>
> wrote:
>
>> This polyfill has been teste against any sort of new or old browsers
>> including IE8 (yes, you read that correctly) and Nokia ASHA Xpress Browser,
>> passing through webOS, FirefoxOS, iOS 5.1 and above, IE9 Mobile up to 11
>> Desktop, and every single browser I could try.
>>
>> The surprising part of doing this polyfill was discovering few
>> inconsistencies between modern browsers and absent implementations of such
>> W3C API which is not bad at all, I would say, and it has tested trying to
>> respect as much as possible all specs.
>>
>> What am I talking about?
>>
>>
>>    - Element#prepend()
>>    - Element#append()
>>    - Element#before()
>>    - Element#after()
>>    - Element#replace()
>>    - Element#remove()
>>    - Element#classList
>>    - CustomEvent constructor
>>
>> First to Element#classList are almost absent everywhere while
>> Element#classList is broken in iOS 5.1 and Nokia ASHA not accepting
>> multiple arguments with methods such add() and remove() and not respecting
>> all rules defined for toggle().
>>
>> Last, but not least, there are still browsers out there that do not
>> support CustomEvent including IE10 (probably 11 too) that requires an
>> initCustomEvent over a document.createEvent('CustomEvent') call.
>>
>> This is one of my best contribution to have a more standard Web and move
>> forward bringing DOM Level 4 API that makes the usage of libraries mostly
>> redundant.
>>
>> I hope you'll appreciate the effort.
>>
>> Here the repo: https://github.com/WebReflection/dom4#dom4
>>
>> It requires conditional comments for IE8 only through:
>>  https://github.com/WebReflection/ie8#ie8
>>
>> It has been tested out there in real IE8 browsers (not the simulated one)
>> and is green.
>>
>> The test suite is here: http://webreflection.github.io/dom4/test/
>>
>> If it's red might be your browser does not respect standards so please
>> let me know and I'll fix that.
>>
>> Best Regards,
>>     Andrea Giammarchi
>>
>>
>>
>>
>>
>>
>>
>>

Received on Sunday, 6 October 2013 16:52:06 UTC