doctyper / flexie

Legacy support for the CSS3 Flexible Box Model
http://flexiejs.com
1.1k stars 110 forks source link

Fix crash if not used box-flex attribute #12

Closed niavok closed 13 years ago

niavok commented 13 years ago

Hi,

if i use an css file with only :

aa {
    box-flex: 1;
}

and if there is not aa element, i will have the following error :

JavaScript - http://127.0.0.1/fr/contribute/check/process-643b1
Event thread: DOMContentLoaded
Uncaught exception: TypeError: Cannot convert 'node.nodeName' to object
Error thrown at line 486, column 13 in <anonymous function>(i, node) in http://127.0.0.1/resources/js/flexie.js:
    opera.postError(hasNodeName);
called via Function.prototype.call() from line 189, column 2 in forEach(object, callback) in http://127.0.0.1/resources/js/flexie.js:
    var name, i = 0, value,
called from line 469, column 5 in <anonymous function>(i, child) in http://127.0.0.1/resources/js/flexie.js:
    forEach(caller, function (i, node) {
called via Function.prototype.call() from line 189, column 2 in forEach(object, callback) in http://127.0.0.1/resources/js/flexie.js:
    var name, i = 0, value,
called from line 462, column 2 in matchFlexChildren(parent, lib, possibleChildren) in http://127.0.0.1/resources/js/flexie.js:
    forEach(possibleChildren, function (i, child) {
called from line 605, column 5 in <anonymous function>(i, target) in http://127.0.0.1/resources/js/flexie.js:
    children = matchFlexChildren(target, lib, flexers.children);
called via Function.prototype.call() from line 189, column 2 in forEach(object, callback) in http://127.0.0.1/resources/js/flexie.js:
    var name, i = 0, value,
called from line 598, column 3 in <anonymous function>(i, flex) in http://127.0.0.1/resources/js/flexie.js:
    forEach(caller, function (i, target) {
called via Function.prototype.call() from line 189, column 2 in forEach(object, callback) in http://127.0.0.1/resources/js/flexie.js:
    var name, i = 0, value,
called from line 547, column 2 in buildFlexieCall(flexers) in http://127.0.0.1/resources/js/flexie.js:
    forEach(flexers.boxes, function (i, flex) {

the crash appear in the le 469, executing node.nodeName.toLowerCase(). When it crash, node.nodeName is undefined

I make a small fix but i'm a noob in javascript so there is maybe some regression.

Thanks for flexie.

Frédéric Bertolus

doctyper commented 13 years ago

Thanks for the fix, I've pulled it in manually here: https://github.com/doctyper/flexie/commit/b3ecfdfb9f52c263946da655306bd2b2e5607357

tcannonfodder commented 13 years ago

This issue still appears to exist. I have some flex-box elements defined in my CSS stylesheet, and if they don't exist on the actual page, Flexie crashes. This time, it's on line 143 of the de-obfuscated (line 5 of the minimized code). Has anyone else run into this issue?