Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: src/caterpillar.py

Issue 1644543005: inject_misc_tags no longer fails if document has no head. Resolves #16. (Closed) Base URL: git@github.com:chromium/caterpillar.git@master
Patch Set: Response to CR + tests Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/caterpillar_test.py » ('j') | src/caterpillar_test.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/caterpillar.py
diff --git a/src/caterpillar.py b/src/caterpillar.py
index 4a0a8b5c38e4e035c8b1953a6cd4babbfe734961..c658708a54f6d69c159f8f93f07db947b8d68e92 100755
--- a/src/caterpillar.py
+++ b/src/caterpillar.py
@@ -286,6 +286,13 @@ def inject_misc_tags(soup, ca_manifest, root_path, html_path):
This can be either absolute or relative.
html_path: Path to the HTML document being modified.
"""
+ if not soup.head:
Matt Giuca 2016/01/29 02:19:26 head = soup.head if not head: ... Now you are g
Matthew Alger 2016/01/29 02:41:51 Okay, done. I'm not sure I see the benefit in this
Matt Giuca 2016/01/29 03:04:13 Mostly performance. You generally want to avoid d
+ head = soup.new_tag('head')
+ if soup.html:
+ soup.html.insert(0, head)
+ else:
+ soup.insert(0, head)
+
# Add manifest link tag.
manifest_path = os.path.join(root_path, PWA_MANIFEST_FILENAME)
manifest_link = soup.new_tag('link', rel='manifest', href=manifest_path)
« no previous file with comments | « no previous file | src/caterpillar_test.py » ('j') | src/caterpillar_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698