mort
mort copied to clipboard
search for dynamic css?
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?
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 + " )"
I would leave this to the user's discretion.
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 abool
if you guessed it, the selector looks dynamic. - [ ] In
getFrom
inselectors.ts
call this and create a new function in all the grep programs to search for this selector (or maybe use the existingcall
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.