Especially when a discretionary is given explicitly or contains
ligatures, the inner list might have a different color attribute than
the disc node. So traverse the replace element like any other nested
list instead of treating a disc as an atomic colored object.
We only have to look at replace because if TeX actually breaks the line
at the disc and .pre/.post is used, TeX moves the lists out of the
discretionary. After that the discretionary node only contains empty sublists, so there is no need for special handling.
Especially when a discretionary is given explicitly or contains ligatures, the inner list might have a different color attribute than the disc node. So traverse the replace element like any other nested list instead of treating a disc as an atomic colored object.
We only have to look at replace because if TeX actually breaks the line at the disc and .pre/.post is used, TeX moves the lists out of the discretionary. After that the discretionary node only contains empty sublists, so there is no need for special handling.
See https://tex.stackexchange.com/questions/493104/how-to-change-color-inside-discretionary-with-luacolor for an example where the problem occured.