@@ -104,11 +104,13 @@ def __init__(self, tagName, attrList=None, isSelfClosing=False, ownerDocument=No
104104 if isSelfClosing is False and tagName in IMPLICIT_SELF_CLOSING_TAGS :
105105 isSelfClosing = True
106106
107+ styleAttr = StyleAttribute ('' , self )
108+
107109 rawSet ('_attributes' , SpecialAttributesDict (self ))
108110 rawSet ('text' , '' )
109111 rawSet ('blocks' , ['' ])
110112 rawSet ('classNames' , [])
111- rawSet ('style' , StyleAttribute ( '' ) )
113+ rawSet ('style' , styleAttr )
112114
113115 rawSet ('isSelfClosing' , isSelfClosing )
114116
@@ -145,7 +147,7 @@ def __setattr__(self, name, value):
145147 return value
146148
147149 if name == 'style' and not isinstance (value , StyleAttribute ):
148- value = StyleAttribute (value )
150+ value = StyleAttribute (value , self )
149151
150152 try :
151153 return object .__setattr__ (self , name , value )
@@ -853,6 +855,7 @@ def getStartTag(self):
853855 '''
854856 attributeString = []
855857 for name , val in self ._attributes .items ():
858+ val = str (val )
856859 if val :
857860 val = escapeQuotes (val )
858861 attributeString .append ('%s="%s"' % (name , val ) )
@@ -1063,7 +1066,11 @@ def setStyle(self, styleName, styleValue):
10631066
10641067 @return - String of current value of "style" after change is made.
10651068 '''
1066- setattr (self .style , styleName , styleValue )
1069+ if 'style' not in self ._attributes :
1070+ self ._attributes ['style' ] = "%s: %s" % (styleName , styleValue )
1071+ else :
1072+ setattr (self ._attributes ['style' ], styleName , styleValue )
1073+ # setattr(self.style, styleName, styleValue)
10671074
10681075 def setStyles (self , styleUpdatesDict ):
10691076 '''
@@ -1078,7 +1085,7 @@ def setStyles(self, styleUpdatesDict):
10781085 @return - String of current value of "style" after change is made.
10791086 '''
10801087 for newName , newValue in styleUpdatesDict .items ():
1081- setattr ( self .style , newName , newValue )
1088+ self .setStyle ( newName , newValue )
10821089
10831090 return self .style
10841091
0 commit comments