Giter Site home page Giter Site logo

Comments (10)

mtetlow avatar mtetlow commented on August 18, 2024

+1, just hit this as well in IE11 http://screencast.com/t/qapokrM6i

from svg4everybody.

mtetlow avatar mtetlow commented on August 18, 2024

Well this is funny. Try doing document.querySelector('#1') in the IE11 javascript console, you get the same syntax error.

Could it be IE puking due to HTML4 technicalities? http://stackoverflow.com/questions/70579/what-are-valid-values-for-the-id-attribute-in-html

from svg4everybody.

fvsch avatar fvsch commented on August 18, 2024

Was going to say "ids must begin with a letter, duh", but apparently that changed in HTML5. Looks like IE/Edge’s implementation of document.querySelector was not updated accordingly.

Can you test if document.getElementById has the same issue? If not, that could be a usable workaround for svg4everybody.

from svg4everybody.

mcmimik avatar mcmimik commented on August 18, 2024

Yes, IE11 looks good with document.getElementById and an identifier starting with an integer.

from svg4everybody.

jonathantneal avatar jonathantneal commented on August 18, 2024

Thanks, @mcmimik, I will add a test for this and resolve it if it is not already.

from svg4everybody.

jonathantneal avatar jonathantneal commented on August 18, 2024

getElementById is not available on detached elements, so I need to figure out a workaround.

from svg4everybody.

fvsch avatar fvsch commented on August 18, 2024

Note that in XML, id attributes (and many other types of "names") cannot start with a number. Compare:
https://www.w3.org/TR/xml11/#NT-NameStartChar
https://www.w3.org/TR/xml11/#NT-NameChar

Authors should probably avoid ids that start with a number.

But if you want to make it work regardless, maybe look into the attribute selector? Tested this in IE11:

document.querySelector('#1000') // SyntaxError
document.querySelector('[id="1000"]') // [object HTMLDivElement]

from svg4everybody.

shawnbot avatar shawnbot commented on August 18, 2024

Yeah, the id attribute selector is more resilient because it also prevents perfectly valid ids (in HTML5) like foo.bar from being interpreted as #foo.bar.

from svg4everybody.

shawnbot avatar shawnbot commented on August 18, 2024

Anyone want to take a look at this commit? I'm pretty sure that the try/catch is necessary for cases in which IE (and older modern browsers) treat some perfectly valid HTML5 IDs as invalid in both Document and DocumentFragment.

FWIW, I used x-browser to test support for DocumentFragment.prototype.getElementById, and found that IE (all versions), Edge, and Safari all lacked it, but the latest Chrome and Firefox support it. (WebKit apparently has a fix in, but I can't tell if/when that will ship.)

from svg4everybody.

shawnbot avatar shawnbot commented on August 18, 2024

Addendum: I was testing the wrong version of Safari via Sauce Labs; in OS X 10.11, Safari includes the WebKit fix for DocumentFragement.prototype.getElementById.

from svg4everybody.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.