You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 5, 2021. It is now read-only.
I'm working on a function for matching CSS selectors and I seem to be having some issues trying to write this function. This is my current code but it doesn't match correctly. Does anyone know of an easier way of matching or one that works? I also tried looking for a function in the Katana source code but I didn't find a matching function.
KatanaStyleRule*rds_theme_find_byrule(rds_theme_t*theme, constchar*strrule) {
KatanaOutput*css=katana_parse(strrule, strlen(strrule), KatanaParserModeSelector);
if (css==NULL) returnNULL;
for (inti=0; i<theme->css->stylesheet->rules.length; i++) {
if (((KatanaRule*)theme->css->stylesheet->rules.data[i])->type==KatanaRuleStyle) {
KatanaStyleRule*rule= (KatanaStyleRule*)theme->css->stylesheet->rules.data[i];
if (rule->selectors->length!=css->selectors->length) continue;
intmatch=1;
for (intx=0; x<css->selectors->length; x++) {
KatanaSelector*asel= (KatanaSelector*)rule->selectors->data[x];
KatanaSelector*bsel= (KatanaSelector*)css->selectors->data[x];
if ((asel->match==bsel->match) ==KatanaSelectorMatchTag) {
if (asel->tag->prefix==NULL&&bsel->tag->prefix==NULL) {
if (!!strcmp(asel->tag->local, bsel->tag->local)) {
match=0;
}
} else {
if (!!strcmp(asel->tag->prefix, bsel->tag->prefix)) {
match=0;
}
if (!!strcmp(asel->tag->local, bsel->tag->local)) {
match=0;
}
}
}
while (asel!=NULL&&bsel!=NULL) {
if (asel->match==bsel->match) {
if (asel->match==KatanaSelectorMatchId||asel->match==KatanaSelectorMatchClass) {
if (!!strcmp(asel->data->value, bsel->data->value)) match=0;
}
} else {
match=0;
break;
}
asel=asel->tagHistory;
bsel=bsel->tagHistory;
}
}
if (!match) continue;
katana_destroy_output(css);
returnrule;
}
}
katana_destroy_output(css);
returnNULL;
}
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm working on a function for matching CSS selectors and I seem to be having some issues trying to write this function. This is my current code but it doesn't match correctly. Does anyone know of an easier way of matching or one that works? I also tried looking for a function in the Katana source code but I didn't find a matching function.
The text was updated successfully, but these errors were encountered: