Add StyleStack.Parent, returning the current style's parent

This commit is contained in:
Christian Muehlhaeuser
2019-12-04 06:38:10 +01:00
parent 9974d6bad9
commit ca06d9968c
+8
View File
@@ -83,6 +83,14 @@ func (s StyleStack) Indent() uint {
return i
}
func (s StyleStack) Parent() *ElementStyle {
if len(s) < 2 {
return s.Current()
}
return cascadeStyles(s[0:len(s)-2], s[len(s)-2])
}
func (s StyleStack) Current() *ElementStyle {
if len(s) == 0 {
return nil