Why chrome remove wrong css class? -
browser: chrome 60.0.3112.78
original:
cssrulelist {0: cssstylerule, 1: cssstylerule, 2: cssstylerule, 3: cssstylerule, length: 4}       length:4   0:cssstylerule {selectortext: ".highlight", style: cssstyledeclaration, type: 1, csstext: ".highlight { background-color: rgb(182, 246, 156); }", parentrule: null, …}   1:cssstylerule {selectortext: ".highlight:hover", style: cssstyledeclaration, type: 1, csstext: ".highlight:hover { background-color: rgb(124, 208, 124); }", parentrule: null, …}   2:cssstylerule {selectortext: ".highlightb6f69c:hover", style: cssstyledeclaration, type: 1, csstext: ".highlightb6f69c:hover { background-color: rgb(124, 208, 124); }", parentrule: null, …}   3:cssstylerule {selectortext: ".highlightb6f69c", style: cssstyledeclaration, type: 1, csstext: ".highlightb6f69c { background-color: rgb(182, 246, 156); }", parentrule: null, …} operation:
> document.getelementbyid('styles').sheet.removerule('.highlightb6f69c')  <- undefined  > document.getelementbyid('styles').sheet.rules  <- cssrulelist {0: cssstylerule, 1: cssstylerule, 2: cssstylerule, 3: cssstylerule, length: 3}       length:3   0:cssstylerule {selectortext: ".highlight:hover", style: cssstyledeclaration, type: 1, csstext: ".highlight:hover { background-color: rgb(124, 208, 124); }", parentrule: null, …}   1:cssstylerule {selectortext: ".highlightb6f69c:hover", style: cssstyledeclaration, type: 1, csstext: ".highlightb6f69c:hover { background-color: rgb(124, 208, 124); }", parentrule: null, …}   2:cssstylerule {selectortext: ".highlightb6f69c", style: cssstyledeclaration, type: 1, csstext: ".highlightb6f69c { background-color: rgb(182, 246, 156); }", parentrule: null, …} i want remove class .highlightb6f69c, chrome remove .highlight instead, why?
from https://developer.mozilla.org/en-us/docs/web/api/cssstylesheet/deleterule
the cssstylesheet.deleterule() method removes style rule current style sheet object.
syntax
stylesheet.deleterule(index)  parameters index long number representing position of rule.
so, reason wrong rule removed because of .highlightb6f69c parsed 0 or nan, removing first one.

Comments
Post a Comment