Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS flow name inconsistent lowercasing results in Javascript errors #35

Open
gpeche opened this issue Jun 17, 2016 · 1 comment
Open
Assignees
Labels

Comments

@gpeche
Copy link

gpeche commented Jun 17, 2016

Supppose you have:

#content { flow-from: myContentFlow } /* NOTE: C and F in myContentFlow are uppercased */
#region { flow-into: myContentFlow }

Internally, the CSS flow name gets lowercased to mycontentflow. If later you execute this Javascript:

var myContentFlow = document.getNamedFlows()["myContentFlow"];

as the key we are looking up is the original and not the lowercased one, lookup fails and myContentFlow gets assigned the undefined value. Usually this reference will get accessed afterwards, causing an exception.

With document.getNamedFlow(...) it gets worse. If you invoke:

var myContentFlow = document.getNamedFlow("myContentFlow");

the parameter to document.getNamedFlow(...) does not get lowercased, with the result that the flow lookup does not succeed, and getNamedFlow(...) returns a new, "empty" flow (why? It's supposed to be a read access). The typical end result is that, without any warnings, the flow looks "dead": events not firing, properties not updating, ... Actually the flow is pretty much alive, it's just that we got a reference to an "artificial" flow instance that will never get updated, instead of a reference to the "good" flow.

document.getNamedFlows().namedItem("myContentFlow")behaves in a similar way to document.getNamedFlow("myContentFlow").

The obvious workaround is to limit flow names to lowercase ones to avoid this problem, but I think this should be addressed: either allow CSS flow names with uppercase characters or uniformly "translate" flow names to the internal form.

@FremyCompany
Copy link
Owner

Oh, waow... Thanks for having a deep look!

The reason you can get a new empty flow for something that does not exist is that, well, it might actually exist by the time you execute your code, but the polyfill didn't yet find out about it because it runs asynchronously; so to get things running, I remember creating the flow on the fly, and the polyfill will use that flow if it gets created later in the async chain.

Now, I am not sure why flow names get lowercased; it is possible this is an issue with my css parser, or it might be me trying too hard to catch common mistakes. If this is the latter, I should just not do this. If this is the former, I should at the very least make the getNamedFlow() and similar calls convert the name to lowercase.

I'll have a look tonight or tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants