Comments (5)
id
s are intentionally replaced because the same component can be included in a single page multiple times. If you want to use id
, just pass them directly in your template, eg. <v-icon id="whatever" name="flag"/>
.
from vue-awesome.
ah right, ok id works on the root, forgot I had my own wrapper around that icon component.
But still a bit weird with the id rewrites, I mean if the ids are being arbitrarily rewritten to some counter, it's not something that can really be referenced in any consistent way, might as well just remove them all together in that case.
Although I feel they should be left alone, up to the dev to decide what should be an id/class and then dealing with the consequences of having duplicates.
For instance the examples here: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/begin
Where the "begin" attribute is given an id reference to a previous animation. There are work arounds with timers for this that I can use, but was kind of nice to just reference them like begin="second.end"
.
from vue-awesome.
Just to add, this could very easily be fixed by just being able to add an id
during a register (or removing the id replacement all together).
icon.js
import Icon from 'vue-awesome/components/Icon';
var id1 = Math.random().toString(36).replace(/[^a-z]+/g, '');
var id2 = Math.random().toString(36).replace(/[^a-z]+/g, '');
Icon.register({
'my/icon/here': {
width: 24,
height: 24,
id: id1,
raw: '/* some animation svg here... */'
}
});
Then in the raw code we can use our ids as we like for animations. This will work for local animations, but continually creates issues without being able to have the root one set.
Also, I've tried doing some wrapper like <g id="myidhere">
but this then gets overridden :-(
from vue-awesome.
You can use class
instead of id
to apply animations. IMO using id
s on reusable components is definitely not a good idea.
from vue-awesome.
Yes, I've tried class, and it's not working.
"IMO using ids on reusable components is definitely not a good idea."
Exactly, that's your opinion, you shouldn't force that on other developers, since they may have other scenarios.
The point I'm trying to make is that it's completely solvable.
- The id rewrite is just arbitrary and does absolutely nothing anyway, it's just overhead really.
- Give the ability to add an "id" that gets attached to the svg element.
Anyway, it's your package, I'll just roll my own or find something else ;-)
from vue-awesome.
Related Issues (20)
- Pseudo element icon HOT 1
- Color prop is not being respected HOT 1
- Hope to use CSS modules to reduce possible style pollution HOT 1
- This ico can not suport with vue 3 or latest HOT 2
- 有没有中文文档,看了费死劲。。。。。 HOT 1
- Cannot find module 'nanoid/non-secure' after upgrade to 4.1.0 HOT 3
- Does this project will support vue3? HOT 4
- Update to vuejs v.3 + TypeScript HOT 7
- 4.2.0之后的版本将components/Icon.vue编译为components/Icon.js导致按需加载找不到Icon组件 HOT 3
- Could not find a declaration file for module HOT 2
- The component does not work anymore on server-side rendering HOT 5
- Can I change the color when `inverse` is true? HOT 1
- html中引入问题 HOT 1
- Publish Icon.vue as well to npm
- Missing style from library HOT 2
- Regression in color behavior HOT 1
- Uncaught (in promise) TypeError: t is not a function HOT 1
- Uncaught TypeError: t is not a function
- update in
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 vue-awesome.