mort icon indicating copy to clipboard operation
mort copied to clipboard

search for dynamic css?

Open joereynolds opened this issue 6 years ago • 3 comments

For example, if it finds something like

.img-file-pdf
.img-file-css
.img-file-jpg
.img-file-png
.img-file-bmp

Maybe it should warn

Multiple classes found with prefix '.img-file', is this dynamically generated?`

Or it could keep backtracking and searching for img-file-pdf, img-file-pd img-file-d etc... until it gets a match?

joereynolds avatar Apr 11 '18 08:04 joereynolds

Here are some examples of dynamic CSS

This is a dumping ground of how people are using CSS dynamically which may get through mort

1.

var class = 'time-' + ( j == 1 ? 'start' : 'end' ) + '-cell';


2.

997: var a = "<div class='" + ((data.overdue == 1) ? 'task-overdue' : 'task-current' ) + "-hover-header'>" + data.action + " ( " + data.something + " ) " + 1001: "<div class='" + ((data.overdue == 1) ? 'task-overdue' : 'task-current' ) + "-hover-id'>thing1" + 1002: "<div class='" + ((data.overdue == 1) ? 'task-overdue' : 'task-current' ) + "-hover-value'> " + data.something + " ( " + data.thing + " )" + 1008: "<div class='" + ((data.overdue == 1) ? 'task-overdue' : 'task-current' ) + "-hover-id'>thing2" + 1009: "<div class='" + ((data.overdue == 1) ? 'task-overdue' : 'task-current' ) + "-hover-value'> " + data.thing + " ( " + data.thing + " )"

joereynolds avatar Apr 27 '18 11:04 joereynolds

I would leave this to the user's discretion.

joereynolds avatar May 28 '18 10:05 joereynolds

Maybe we can list "possible" matches by doing something like

rg yoursearch.*andtherestofit

Maybe as a first pass, we can do something like the following

  • [ ] Create a function in selector.ts called (something like) isProbablyDynamic this should return a bool if you guessed it, the selector looks dynamic.
  • [ ] In getFrom in selectors.ts call this and create a new function in all the grep programs to search for this selector (or maybe use the existing call function but pass through a different selector name

How does a selector look dynamic? For now we can go with keywords like hover, start, end. This will be a hardcoded string which in the future can either go in as a config, or ideally, we can offer a better soution.

Grepping for it:

Example selector: my-box-hover

Example pattern: my-box.*hover

The more examples of dynamic css we can get, the better.

Questions

Should we bother doing the exact string match if a selector looks dynamic? It's a wasted call.

joereynolds avatar Jun 05 '18 10:06 joereynolds