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

Add all SVG properties #283

Open
skrat opened this issue Jun 1, 2012 · 24 comments
Open

Add all SVG properties #283

skrat opened this issue Jun 1, 2012 · 24 comments

Comments

@skrat
Copy link

skrat commented Jun 1, 2012

I think this might be useful as SVG is becoming more common. It should recognize all non-CSS2 SVG properties as specified here http://www.w3.org/TR/SVG/styling.html#SVGStylingProperties

I tried myself but adding them to known-properties.js and building, doesn't seem to work.

@mahonnaise
Copy link
Contributor

I tried myself but adding them to known-properties.js and building, doesn't seem to work.

That's because the properties object in src/rules/known-properties.js isn't actually used. Whether the property is valid or not is determined by the parser-lib.

@skrat
Copy link
Author

skrat commented Jun 4, 2012

All right, can it be removed then to avoid further confusion?

mahonnaise added a commit to mahonnaise/csslint that referenced this issue Jun 6, 2012
@mahonnaise
Copy link
Contributor

Sure.

@nzakas
Copy link
Contributor

nzakas commented Jul 23, 2012

@stubbornella thoughts on adding SVG properties?

@stubbornella
Copy link
Member

I haven't seen this in the wild. @skrat - Can you give examples of svg properties used live? Preferably on large commercial type sites rather than experimental blog type sites.

@mahonnaise
Copy link
Contributor

The almighty pointer-events property is from SVG.

[pointer-events:none makes clicks pass right through your object. This is neat if you want fade out effects without obstructing the clickable areas of elements below your gradient.]

SVG filters are also kinda cool. However, right now they are only supported by Gecko (outside of SVG, that is).

@skrat
Copy link
Author

skrat commented Jul 31, 2012

This is the killer feature of SVG over Canvas. I use it to style complex
drawing application built with SVG embedded in HTML. Other use cases might
include styling graphs and plots and any other app that uses SVG for the
view.

Sent from my HAL9000

@joshcarr
Copy link

@stubbornella, @skrat and @nzakas The popular d3.js project (with ~8600 stars and ~1200 forks) is a big proponent of using SVG and styling with CSS. D3 is used by the NY Times, Square, GitHub and other large commercial orgs. Consider this another vote for adding these properties to the 'known' list.

@partap
Copy link

partap commented Oct 18, 2012

@joshcarr I came here to say that. I've never used SVG styles before, but my new project uses d3, and now csslint is bitchy. :)

@SoftwareDreamer
Copy link

csslint is in the way of d3.js, for sure.. who had the idea of really leaving them out, anyway? Anyway.. please add them.

@timmywil
Copy link

A friendly bump. Sure would be nice to have this.

@bigethan
Copy link

Using SVG styles to color some D3 charts at Trulia. Not an experimental blog :-)

@seiyria
Copy link

seiyria commented Nov 4, 2013

I'm using grunt in conjunction with csslint right now on a primarily d3.js project. Since I use a lot of SVG properties, csslint is currently not that helpful to me. +1

@sbking
Copy link

sbking commented Nov 18, 2013

Using Snap.svg with styles in CSS rather than my JavaScript. This would really be a nice feature. +1

@bizob2828
Copy link

any reason for not accepting this pull request? I'm in the same predicament as others, using svg properties to style d3 graphs

@nschonni
Copy link
Member

This isn't a pull request, see CSSLint/parser-lib#28 and CSSLint/parser-lib#97 for the discussion on why those PRs haven't been included.

@ghost
Copy link

ghost commented May 15, 2015

The linter is flagging the property fill, which is common in CSS when using inline-SVG iconography.

@himedlooff
Copy link

👍 SVG's are now promoted as best practice especially for icons.

@qm3ster
Copy link

qm3ster commented May 6, 2016

In the meantime, how do I make it ignore specifically the property 'fill'?

@kschaefe
Copy link

kschaefe commented Nov 9, 2016

It just complained about fill: transparent in my CSS. It doesn't know what transparent is.

@CBuntrock
Copy link

Will this be done? having many errors of unknown property since I use more svg now

@josezulu
Copy link

CBuntrock: I had the same issues until I realised my csslint version was outdated. Updated it and check again.

@jmisur
Copy link

jmisur commented Jul 20, 2017

for anyone who struggles with this, add this rule to your gulpfile and set "known-properties": false in .csslintrc.
It reports all properties which were not found in svgProperties just like known-properties rule would.

// CSSLint doesn't support SVG properties, so we create our custom rule based on
// https://github.com/CSSLint/csslint/blob/master/src/rules/known-properties.js
csslint.addRule({
    // rule information
    id: "svg",
    name: "SVG properties",
    desc: "Adds support for SVG properties",
    url: "",
    browsers: "All",

    // initialization
    init: function(parser, reporter) {
        "use strict";
        const rule = this;
        const svgProperties = ['fill', 'fill-opacity', 'stroke', 'stroke-width', 'shape-rendering', 'text-anchor'];

        parser.addListener("property", function(event) {
            if (event.invalid) {
                const propertyName = event.property.toString().toLowerCase();
                if (svgProperties.indexOf(propertyName) < 0) {
                    reporter.report(event.invalid.message, event.line, event.col, rule);
                }
            }
        });
    }
});

@wkeese
Copy link

wkeese commented May 31, 2018

I think you can close this ticket; all the properties have been added, see https://github.com/CSSLint/parser-lib/blob/master/src/css/Properties.js.

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

No branches or pull requests