Comments (10)
+1, just hit this as well in IE11 http://screencast.com/t/qapokrM6i
from svg4everybody.
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.
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.
Yes, IE11 looks good with document.getElementById
and an identifier starting with an integer.
from svg4everybody.
Thanks, @mcmimik, I will add a test for this and resolve it if it is not already.
from svg4everybody.
getElementById
is not available on detached elements, so I need to figure out a workaround.
from svg4everybody.
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.
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.
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.
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)
- Not working for MS Edge HOT 3
- can't make href work using svg4everybody HOT 1
- svg4everybody is not defined
- Add workaround for SVG print bug in Firefox
- svg-chrom HOT 1
- SVG transform animateTransform not working in IE11 and Edge 42
- linearGradient for svg4everybody HOT 2
- run the polyfill only on selected dom element and its children
- Validate Not Running After Page Start
- Inlining External SVG
- Inlining External SVG from sprite, SVG doesn't display correctly HOT 3
- PreserveAspectRatio attribute is stripped out on IE11
- Add option to always replace contents ignoring browser support HOT 2
- Empty XHR embeds after splice(0)
- import does not seem to work properly
- Generate png from svg
- Svg4everybody not working on all svgs in IE11 HOT 2
- Suggestion: Suggest loading the script with the nomodule attribute HOT 2
- Issue with iPhone5 / Safari6
- Link to kartikprabhu.com "Inline SVG Icons" is broken; Archive.org link provided
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svg4everybody.