Bug 25833
| Summary: | Page that performs syntax highlighting on <code> elements in JS looks wrong when loaded from web archive | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Reiner Pittinger <pittinger> |
| Component: | Layout and Rendering | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | beidson, mrowe |
| Priority: | P2 | Keywords: | NeedsReduction |
| Version: | 528+ (Nightly build) | ||
| Hardware: | Mac | ||
| OS: | OS X 10.5 | ||
| URL: | http://guides.rubyonrails.org/i18n.html | ||
Reiner Pittinger
When saving a page with a <code>-element, the saved page is displayed incorrectly when viewing the saved archive.
Reproduce:
1. Go to http://guides.rubyonrails.org/i18n.html
2. Look at the correctly displayed code block (below "1.2 The Public I18n API").
3. Save the website as a webarchive.
4. Open the archive and look at the same document part again. Now you will see text like " class="comment">", which is actually a broken <span>-element.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Mark Rowe (bdash)
Looking in the web inspector, the markup for the code block on the original page looks like so:
<div class="code_container"><code class="ruby">
translate <span class="comment"># Lookup text translations</span>
localize <span class="comment"># Localize Date and Time objects to local formats</span>
</code></div>
This matches what is in the document source. When loaded from the web archive, the markup for the code block looks like so:
<div class="code_container"><code class="ruby">
translate <span><span class="keywords">class</span>=<span class="string">"comment"</span>><span class="comment"># Lookup text translations</span></span>
localize <span><span class="keywords">class</span>=<span class="string">"comment"</span>><span class="comment"># Localize Date and Time objects to local formats</span></span>
</code></div>
Looking at the source of the main resource via View -> Source shows the original, correct markup.
Mark Rowe (bdash)
I was mistaken: the markup in the original page looks like:
<div class="code_container"><code class="ruby">
translate # Lookup text translations
localize # Localize Date and Time objects to local formats
</code></div>
Since the DOM being displayed contains extra elements related to syntax highlighting, I suspect there is syntax highlighting being performed via JavaScript. When saving as a web archive we serialize from the DOM at that point in time. When the document is then loaded once more the syntax highlighting is run on the already-highlighted element, which causes it to attempt to highlight the presentational markup that the earlier syntax highlighting introduced.
Mark Rowe (bdash)
I知 not sure whether this is really a bug.
Mark Rowe (bdash)
Brady, what do you think we should do with this?