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

Unified Diff: src/caterpillar.py

Issue 1675133002: inject_script_tags no longer crashes when there is no body tag. (Closed) Base URL: https://github.com/chromium/caterpillar.git@master
Patch Set: Created 4 years, 10 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') | no next file with comments »
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 27d3c3bb6f4ebd88f306b51197d66fd6e7486f09..47f43a5a6498b3a169f69942f11d9c3bd4c692e9 100755
--- a/src/caterpillar.py
+++ b/src/caterpillar.py
@@ -271,7 +271,13 @@ def inject_script_tags(soup, required_js_paths, root_path, boilerplate_dir,
path = os.path.join(root_path, boilerplate_dir, script_path)
script = soup.new_tag('script', src=path)
if first_script is None:
- soup.body.append(script)
+ target = soup.body
+ if not target:
+ if soup.html:
+ target = soup.html
+ else:
+ target = soup
Matt Giuca 2016/02/08 04:28:39 I'm confused; I thought you did this change awhile
Matthew Alger 2016/02/08 04:29:57 That was head tags and in another function. I thi
Matt Giuca 2016/02/08 05:59:52 Acknowledged.
+ target.append(script)
else:
first_script.insert_before(script)
first_script = script
« no previous file with comments | « no previous file | src/caterpillar_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698