Skip to content

Commit b15d344

Browse files
committed
Check for tagName attr before checking script tag
- Added a comment node to example.html to ensure non-failure in test
1 parent 8861dbe commit b15d344

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

microdata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def _text(e):
209209
chunks = []
210210
if e.nodeType == e.TEXT_NODE:
211211
chunks.append(e.data)
212-
elif e.tagName == 'script':
212+
elif hasattr(e, 'tagName') and e.tagName == 'script':
213213
return ''
214214
for child in e.childNodes:
215215
chunks.append(_text(child))

test-data/example.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<span itemprop="streetAddress">
1616
20341 Whitworth Institute
1717
405 N. Whitworth
18+
<!-- Comment Node -->
1819
<script>
1920
// Unrelated text
2021
</script>

0 commit comments

Comments
 (0)