Code Monkey home page Code Monkey logo

css-what's People

Contributors

chocolateboy avatar churkin avatar dependabot-preview[bot] avatar dependabot[bot] avatar dshadrick avatar eightarmcode avatar eps1lon avatar fb55 avatar ganeshv avatar jannispl avatar jspri avatar kevva avatar klapec avatar kpdecker avatar mathew-kurian avatar nageshlop avatar phated avatar ryuugan avatar semigradsky avatar shinnn avatar slaks avatar spocke avatar thecodrr avatar zicsus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

css-what's Issues

npm vulnerabilities

Please have a look.

# npm audit report

css-what  <5.0.1
Severity: high
Denial of Service - https://npmjs.com/advisories/1754
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/css-what
  css-select  <=3.1.2
  Depends on vulnerable versions of css-what
  node_modules/css-select
    react-native-svg  >=9.13.0
    Depends on vulnerable versions of css-select
    node_modules/react-native-svg
      @ui-kitten/components  >=5.0.0-alpha.1
      Depends on vulnerable versions of react-native-svg
      node_modules/@ui-kitten/components
      @ui-kitten/eva-icons  >=5.0.0-alpha.1
      Depends on vulnerable versions of react-native-svg
      node_modules/@ui-kitten/eva-icons

5 high severity vulnerabilities

SyntaxError: parenthesis not matched

Selector gave me error: SyntaxError: parenthesis not matched

script:contains("setImgSrc(")

I tried parsing it for testing

const CSSwhat = require('css-what');
CSSwhat.parse('script:contains("setImgSrc(")');

but got error: Uncaught TypeError: CSSwhat.parse is not a function
at parseSelector (/home/.../node_modules/css-what/index.js:226:14)
... so testing has to wait

but why I got this parenthesis error, "(" is as text inside data field, not sure ... maybe you can provide some examples how pseudos data field should be used.

An in-range update of jshint is breaking the build 🚨

Version 2.9.5 of jshint just got published.

Branch Build failing 🚨
Dependency jshint
Current Version 2.9.4
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As jshint is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes JSHint 2.9.5

2.9.5 (2017-06-22)

Bug Fixes

  • Account for hoisting of importing bindings (bd36953)
  • Add onmessage to vars.worker (540ed85)
  • Added missing "Storage" browser variable (8cfe5ad)
  • Avoid crash when peeking past end of prog (c083866)
  • Avoid false positive (44d9e0b)
  • Close synthetic scope for labeled blocks (5f0f789)
  • Fail gracefully on invalid if syntax (#3103) (8c6ac87)
  • Honor "ignore" file when linting STDIN (d4f83a4)
  • Parse for-in/of head LHS as asnmt target (da52ad9)
  • Removed warning message W041 (#3115) (376fa62)
  • Throw W033 instead of E058 when the ; after a do-while stmt is missing (6907cd4)

Features

Commits

The new version differs by 42 commits.

  • d3d84ae v2.9.5
  • 481cdca Merge branch 'W083'
  • ad7df61 [[TEST]] Update tests to reflect new W083 language
  • 5967e61 [[TEST]] Less ambiguous message for W083
  • cc215bd [[CHORE]] Update Test262
  • e6c89f0 [[CHORE]] Fix bug in test script
  • 5b957f6 Merge pull request #3126 from jugglinmike/for-lhs
  • da52ad9 [[FIX]] Parse for-in/of head LHS as asnmt target
  • b075919 [[FEAT]] Add MediaRecorder to vars.js
  • 24b8c97 Merge pull request #3066 from jugglinmike/asi-dowhile-es6-updated
  • 29c359f Merge pull request #3064 from jugglinmike/improve-yield-messages
  • c083866 [[FIX]] Avoid crash when peeking past end of prog
  • 5f0f789 [[FIX]] Close synthetic scope for labeled blocks
  • 70f9ca2 Merge remote-tracking branch 'jugglinmike/2358-improve-unused-desc'
  • bd36953 [[FIX]] Account for hoisting of importing bindings

There are 42 commits in total.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Parsing animations

Hi!

Looks like this library can't parse the CSS animation declarations 😅

Support for customizable attribute selectors?

Wondering if you'd be interested in adding customizable attribute selectors as an option for the parser? # = id and . = class are currently hard-coded, which is obviously what you'd expect to see for HTML, but if you're trying to parse something else (e.g. JSX), it might be valuable to map those attribute selectors to something else (e.g. className for React).

I'm more than happy to make a PR if that's something you'd like to add to this project :) Thanks!

Escaped ID selectors crash the parser

The Acid3 test contains the selector #\ (note trailing space), which is supposed to match id=" ".

Parsing this selector throws an exception:

TypeError: Cannot read property '0' of null
    at getName (CSSselect/node_modules/CSSwhat/index.js:61:36)
    at parse (CSSselect/node_modules/CSSwhat/index.js:83:13)
    at Function.parse (CSSselect/index.js:657:18)

Possible issue with selector '#.identifier'

When an id selector contains a period I get a runtime error here:

https://github.com/fb55/css-what/blob/master/index.js#L97

Such as (truncated for brevity):

TypeError: Cannot read property '0' of null
    at getName (/home/muji/git/makestatic/compiler/packages/auto-title/node_modules/css-what/index.js:97:36)
    at parseSelector (/home/muji/git/makestatic/compiler/packages/auto-title/node_modules/css-what/index.js:145:13)
    at parse (/home/muji/git/makestatic/compiler/packages/auto-title/node_modules/css-what/index.js:82:13)
    at Function.compileUnsafe (/home/muji/git/makestatic/compiler/packages/auto-title/node_modules/css-select/lib/compile.js:33:15)
    at Function.select [as selectOne] (/home/muji/git/makestatic/compiler/packages/auto-title/node_modules/css-select/index.js:20:51)
...

As browsers handle this fine I am wondering whether it is legal to have a period in an id as far as selectors go.

Can you advise? If you feel it's worth patching I am happy to give it a shot and submit a PR.

what's the element action?

I would think:

require('css-what')('.hi')

would end up looking like:

{
  type: 'attribute', 
  action: 'equals',
  name: 'class',
  value: 'hi'
}

or [class="hi"].

XML parsing

Hi !

I'm using cheerio, which use this module.
I use it as an XML parser and I have a problem with index.js line 94. The regex doesn't match my selector.

re_attr = /^\s*((?:\\.|[\w\u00c0-\uFFFF\-])+)\s*(?:(\S?)=\s*(?:(['"])(.*?)\3|(#?(?:\\.|[\w\u00c0-\uFFFF\-])*)|)|)\s*(i)?\]/;
data = 'resource[rel=host/simplemodel]'.match(re_attr);
console.log(data) // null

in index.js

selector = selector.substr(data[0].length);

Thanks !

after upgrade getting "parse is not a function error

After upgrade to version "5.0.1" getting an error parse is not a function

Application is created using Create React app template

Error:

node_modules\css-select\lib\compile.js:31
var token = parse(selector, options);
^

TypeError: parse is not a function

Version: "5.0.1"

License?

Are you letting people use this code that you published here?

If so, please put an Open Source license on the code -- e.g. the MIT license is very common for this kind of software. Here's the text you can use. Just add a file called LICENSE, or add this text to your README, and we'll know that you are giving people permission to use your code. If this is your code, put in your name for the copyright. If you work for a company and they own your IP, then use your company's name (with permission of course).

Thanks!

---------------->

MIT License
Copyright (c) 2012 [YOUR NAME or YOUR COMPANY'S NAME]. All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

union with `postcss-selector-parser`

Hello, great work, what do you think if we union around postcss-selector-parser, many tools need this module and we can work together on one project

Does not parse anything inside :host() and :host-context()

Hi,
So I found out that css-what does not parse anything inside :host() and :host-context() and just return the value as it is.

For example:
If you try to parse :host-context(#test.cl) it returns-
[[{type: "pseudo", name: "host-context", data: "#test.cl"}]]

Expected output-
[[{type: "pseudo", name: "host-context", data: [[ {type:"attribute", name:"id", value="test"....}, {type:"attribute", name:"class", value="cl"....} ]] }]]

Thanks!

Incorrect handle escaping

https://www.w3.org/TR/selectors-4/#case-sensitive

CSSwhat.parse('#foo\>a')

Output:

[
  [
    {
      type: 'attribute',
      name: 'id',
      action: 'equals',
      value: 'foo',
      ignoreCase: false,
      namespace: null
    },
    { type: 'child' },
    { type: 'tag', name: 'a', namespace: null }
  ]
]

Expected output:

[
  [
    {
      type: 'attribute',
      name: 'id',
      action: 'equals',
      value: 'foo>a',
      ignoreCase: false,
      namespace: null
    }
  ]
]

CSSwhat.parse('.h-0\.5')

Output:

[
  [
    {
      type: 'attribute',
      name: 'class',
      action: 'element',
      value: 'h-0',
      ignoreCase: false,
      namespace: null
    },
    {
      type: 'attribute',
      name: 'class',
      action: 'element',
      value: '5',
      ignoreCase: false,
      namespace: null
    }
  ]
]

Expected output:

[
  [
    {
      type: 'attribute',
      name: 'class',
      action: 'element',
      value: 'h-0.5',
      ignoreCase: false,
      namespace: null
    }
  ]
]

parse xml namespaces

css-what breaks on xml documents with namespaces

use case: parse and query docx documents with <w:t>hello</w:t> etc.

actual

require('css-what').parse('w:t', { xmlMode: true }) ==
[
  [
    { type: 'tag', name: 'w', namespace: null },
    { type: 'pseudo', name: 't', data: null }
  ]
]

css-select throws Error: unmatched pseudo-class :t

expected

require('css-what').parse('w:t', { xmlMode: true }) ==
[
  [
    { type: 'tag', name: 't', namespace: 'w' }
  ]
]

possible solution:
parse only valid pseudo elements (:first-child etc), and treat the rest as namespaced tags
and/or add an option to disable all pseudo elements, and treat them all as namespaced tags

Issue with superscript

Hello.

The following code

require('css-what')('.m²')

throws an exception

SyntaxError: Unmatched selector: ²

But the default document.querySelector('.m²') works, so .m² is a valid selector.

Update to latest 'laravel-mix'

When upgrading the 'laravel-mix' package to the latest 6.0.24. version, your package has some problem (see below). Would you be so kind to fix it, please? I don't have 5th version of the 'laravel-mix' anymore...

Screenshot_1

Fails to parse ::part()

It appears ::part() selectors do not parse and instead emit an error:

console.log(cssWhat.parse('foo::part(bar)'));
Error: Unmatched selector: )

css-what has Denial of Service

# npm audit report

css-what  <5.0.1
Severity: high
Denial of Service - https://npmjs.com/advisories/1754
No fix available

When a fix is available, it is going to take a while for this upstream project to make it to us.

=> Found "svgo#[email protected]"
info Reasons this module exists
   - "@quasar#app#cssnano#cssnano-preset-default#postcss-svgo#svgo#css-select" depends on it
   - Hoisted from "@quasar#app#cssnano#cssnano-preset-default#postcss-svgo#svgo#css-select#css-what"

We have 5 levels that will need the update before we can get it. :(

compile method does not throw error

the compile method does not throw an error in case of bad selectors are given.

const cssSelect = require('css-select');
cssSelect.compile("##button"); 

the compile method returns with a function, but an error expected Uncaught Error: Expected name, found ##button

The problem is with the css-what 's latest version where parser method does not throw the error.

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The new Node.js version is in-range for the engines in 1 of your package.json files, so that was left alone

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Broken on node.js < 7 due to Object.values usage

Hi,

one of my legacy apps that happens to use grunt and grunt-svg-sprite has begun failing to build recently and apparently this is due to a recent change in css-what which happened in commit 138b101: Object.values is not supported in node.js < 7, despite css-what having

    "engines": {
        "node": ">= 6"
    },

declared in package.json.

Could you please either update the engines section in package.json to correctly express which node.js version is actually supported or update your code to not use Object.values?
I've made a PR: #295

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.