Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Adopting nodes ignores styling
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Adopting nodes ignores styling



We have a system where:

1. A chunk of HTML is loaded into an offscreen webview
2. Once the webview has loaded, the DOM nodes making up the content are brought across to the onscreen webview
3. The nodes are used to replace existing nodes in the onscreen DOM

Originally, we were using -[DOMDocument importNode:deep] to copy across the nodes. Then, at some point I discovered -adoptNode: which better matches what we want. It has two advantages for us:

- More memory efficient, since the nodes are moved rather than copied
- Doesn't throw an exception if the HTML fed into the offscreen produced a non-standard DOM tree. e.g. a user entered custom HTML which places content inside an element which is supposed to be empty

But I've realised there's quite a big bug. After inserting the nodes into the main document, most CSS rules that match don't take effect. For example, if the offscreen HTML is a Contact Form, it's supposed to have this CSS applied to a field:

ContactElement.css:
textarea.fullWidth, input.fullWidth, select.fullWidth {
• width: 96%;
• margin: 4px 0;
}

Loading the HTML directly in the onscreen webview, correctly matches that rule. However, bringing in the exact same HTML from the offscreen webview only matches rules from main.css and user agent.

Is this the intended behaviour of -adoptNode: or a bug?
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webkitsdk-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.