![]() |
![]() ![]() |
![]() |
lolothedragon |
![]()
Post
#1
|
Newbie ![]() Group: Members Posts: 10 Joined: 7-May 25 Member No.: 29,456 ![]() |
Hi guys,
This line https://www.w3.org/TR/SVG2/paths.html#TheDProperty defined d as a property, but it is in fact an attribute, we can verify it by following code <path id='p1' d='M0,0 L10,10'/> p1.d == null p1.getAttribute('d') == 'M0,0 L10,10' how does this happen? |
Christian J |
![]()
Post
#2
|
. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: WDG Moderators Posts: 9,806 Joined: 10-August 06 Member No.: 7 ![]() |
I don't know. This section: https://www.w3.org/TR/SVG2/paths.html#PathElement lists a number of attributes, and then "d" as a Geometry property, so it seems intentional. FWIW, this whole page uses the term "properties" too: https://www.w3.org/TR/SVG2/propidx.html
![]() |
pandy |
![]()
Post
#3
|
🌟Computer says no🌟 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: WDG Moderators Posts: 20,815 Joined: 9-August 06 Member No.: 6 ![]() |
Can't it be both? As far as JS is concerned it's a property. But when used in markup it needs to be an attribute.
|
Christian J |
![]()
Post
#4
|
. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: WDG Moderators Posts: 9,806 Joined: 10-August 06 Member No.: 7 ![]() |
Someone wrote that in the DOM, HTML attributes are called properties. But I haven't found an official source for that yet.
I don't know much about SVG. Is it basically just normal HTML, or does it involve other mystical things as well? |
pandy |
![]()
Post
#5
|
🌟Computer says no🌟 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: WDG Moderators Posts: 20,815 Joined: 9-August 06 Member No.: 6 ![]() |
Someone wrote that in the DOM, HTML attributes are called properties. But I haven't found an official source for that yet. I don't know much about SVG. Is it basically just normal HTML, or does it involve other mystical things as well? I was interested in SVG when it was new. That's loooong ago now. It isn't HTML, but a flavour of XML. So yes, it's markup. I think it's logical. Two different languages. One markup language and a programming language. They don't use the same lingo. What's just a kind of declaration (an attribute) in a markup language can be picked up by JS/DOM that uses it as a property it can do things with. The real problem, I think, is that they chose to describe SVG primarily from a DOM point of view, not a markup POV. It's sort of implied that you already get the markup part. It all gets mixed up which I think makes it harder to grasp. But I've always preferred step by step learning. For me it's easier to first learn the markup bit, the syntax and terminology, and then move on to JS/DOM. But I come from markup, not programming. YMMV. Back in the day I bought a book on SVG. I never finished it (it's very thick!), but read the introductory chapters. It was more structured and didn't mix lingos as freely as the spec does but took it as I like it, step by step. I understood what I read and even managed to write a few simple SVG animations. It should also be said that of course the spec isn't a tutorial. So maybe the best way to tackle it is to read tutorials first or in parallel to the spec. |
Christian J |
![]()
Post
#6
|
. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: WDG Moderators Posts: 9,806 Joined: 10-August 06 Member No.: 7 ![]() |
Now that I studied a little more (I still know nothing about this), it might primarily be about CSS properties:
"Elements in an SVG document can be styled using CSS. Most visual characteristics and some aspects of element geometry are controlled using CSS properties. For example, the fill property controls the paint used to fill the inside of a shape, and the width and height properties are used to control the size of a ‘rect’ element. MDN mentions "d" as both an attribute and a property: "Using d as a CSS property There are also separate lists of attributes and properties at W3C, so it may not just be about the "d" property: https://www.w3.org/TR/SVG/propidx.html https://www.w3.org/TR/SVG/attindex.html as well as "Geometry properties": https://www.w3.org/TR/SVG/geometry.html ...yet "d" is not listed on any of those three pages. Am I looking at different specs or SVG versions? ![]() |
pandy |
![]()
Post
#7
|
🌟Computer says no🌟 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: WDG Moderators Posts: 20,815 Joined: 9-August 06 Member No.: 6 ![]() |
Yeah. CSS too. It's the same with HTML and CSS. In HTML a color is an attribut, in CSS a property.
QUOTE ...yet "d" is not listed on any of those three pages. Am I looking at different specs or SVG versions? I don't know. Haven't looked at an SVG spec for more than 10 years. ![]() |
![]() ![]() |
![]() |
Lo-Fi Version | Time is now: 19th May 2025 - 12:20 AM |