Closed Bug 1057102 Opened 10 years ago Closed 6 years ago

font_size_utils.js: h1 with children does not see child content modifications

Categories

(Firefox OS Graveyard :: Gaia, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: jrburke, Unassigned)

Details

(Whiteboard: [systemsfe])

For bug 800402, email is introducing some child elements in the h1 tag for the message_list, one to hold the folder name, the other to hold the unread count.

In the process of doing that, it looked like it was no longer getting font resizing. There are more details in bug 800402 comment 30, but I ended up with this patch locally to get the resizes from this library:

diff --git a/shared/js/font_size_utils.js b/shared/js/font_size_utils.js
index 52a72f1..228e535 100644
--- a/shared/js/font_size_utils.js
+++ b/shared/js/font_size_utils.js
@@ -105,7 +105,7 @@
     _observeHeaderChanges: function(element) {
       var observer = this._getTextChangeObserver();
       // Listen for any changes in the child nodes of the header.
-      observer.observe(element, { childList: true });
+      observer.observe(element, { childList: true, subtree: true });
     },

     /**
@@ -115,8 +115,13 @@
      * @param {HTMLElement} header h1 text inside header to reformat.
      */
     _reformatHeaderText: function(header) {
+      // Since subtree listening is in effect, find the actual header.
+      while(header && !this.getAllowedSizes(header).length) {
+        header = header.parentNode;
+      }
+
       // Skip resize logic if header has no content, ie before localization.
-      if (header.textContent.trim() === '') {
+      if (!header && header.textContent.trim() === '') {
         return;
       }

If this seems like a reasonable change for the library, I can work up a more formal pull request. 

However, I wanted to check to see if this sort of thing had been discussed before, or perhaps I missed something that the email case should just do instead. For now, email will just manually call the resizing when it knows something changed instead of use the approach above.
Firefox OS is not being worked on
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.