Skip to content

Commit

Permalink
Merge pull request #42 from APN-Pucky/main
Browse files Browse the repository at this point in the history
Add default variable for missing Property
  • Loading branch information
jaraco committed Mar 30, 2024
2 parents 4d4e87f + 2158587 commit fbf8675
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cssutils/css/cssstyledeclaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def getPropertyCSSValue(self, name, normalize=True):
else:
return None

def getPropertyValue(self, name, normalize=True):
def getPropertyValue(self, name, normalize=True, default=''):
r"""
:param name:
of the CSS property, always lowercase (even if not normalized)
Expand All @@ -512,16 +512,18 @@ def getPropertyValue(self, name, normalize=True):
If ``False`` may return **NOT** the effective value but the
effective for the unnormalized name.
:param default:
value to be returned if the property has not been set.
:returns:
the value of the effective property if it has been explicitly set
for this declaration block. Returns the empty string if the
for this declaration block. Returns `default` if the
property has not been set.
"""
p = self.getProperty(name, normalize)
if p:
return p.value
else:
return ''
return default

def getPropertyPriority(self, name, normalize=True):
r"""
Expand Down
1 change: 1 addition & 0 deletions newsfragments/42.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
getPropertyValue now allows specifying a default value.

0 comments on commit fbf8675

Please sign in to comment.