From 4abda26e927070d8c29aee0b8015a87b9e64dc46 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 16 Jun 2022 12:49:56 +0530 Subject: [PATCH] Edit book: Live CSS: Fix @namespace rules causing jumping to rule definition to go to the wrong definition. Fixes #1978500 [Private bug](https://bugs.launchpad.net/calibre/+bug/1978500) --- src/pyj/live_css.pyj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pyj/live_css.pyj b/src/pyj/live_css.pyj index 3f3a71952a..90972c92c4 100644 --- a/src/pyj/live_css.pyj +++ b/src/pyj/live_css.pyj @@ -179,13 +179,16 @@ def selector_matches(node, selector): def process_rules(node, rules, address, sheet, sheet_index, all_properties, node_style, is_ancestor, ans): + offset = 0 for rule_index in range(rules.length): rule = rules[rule_index] - rule_address = address.concat(v'[rule_index]') + rule_address = address.concat(v'[rule_index - offset]') if rule.type is CSSRule.MEDIA_RULE: process_rules(node, rule.cssRules, rule_address, sheet, sheet_index, all_properties, node_style, is_ancestor, ans) continue if rule.type is not CSSRule.STYLE_RULE: + if rule.type is CSSRule.NAMESPACE_RULE: + offset += 1 continue st = rule.selectorText if not selector_matches(node, st):