Bug 1570954 - Port bug 1479125 to Thunderbird: Rewrite callers firstChild/lastChild/childNodes/previousSibling/nextSibling with firstElementChild/lastElementChild/children/previousElementSibling/nextElementSibling. r=pmorris
This allows the JS to work in HTML documents, where whitespace is preserved. In XUL
documents, whitespace is ignored when parsing so text nodes are generally not returned.
The following changes were made, with manual cleanups as necessary (i.e. when firstChild actually refers to a text node, or when firstChild is used in a loop to empty out an element):
firstChild->firstElementChild
lastChild->lastElementChild
nextSibling->nextElementSibling
previousSibling->previousElementSibling
childNodes->children
# firstChild -> firstElementChild
grep -rl '\bfirstChild\b' --exclude-dir=.hg --exclude-dir=suite --exclude-dir=editor . | xargs sed -i 's/\bfirstChild\b/firstElementChild/g'
# lastChild->lastElementChild
grep -rl '\lastChild\b' --exclude-dir=.hg --exclude-dir=suite --exclude-dir=editor . | xargs sed -i 's/\blastChild\b/lastElementChild/g'
# nextSibling->nextElementSibling
grep -rl '\nextSibling\b' --exclude-dir=.hg --exclude-dir=suite --exclude-dir=editor . | xargs sed -i 's/\bnextSibling\b/nextElementSibling/g'
# previousSibling->previousElementSibling
grep -rl '\previousSibling\b' --exclude-dir=.hg --exclude-dir=suite --exclude-dir=editor . | xargs sed -i 's/\bpreviousSibling\b/previousElementSibling/g'
# childNodes->children
grep -rl '\childNodes\b' --exclude-dir=.hg --exclude-dir=suite --exclude-dir=editor . | xargs sed -i 's/\bchildNodes\b/children/g'
# revert for clearning out. lastElementChild.remove() -> lastChild.remove()
grep -rl '\lastElementChild.remove\b' --exclude-dir=.hg --exclude-dir=suite --exclude-dir=editor . | xargs sed -i 's/\lastElementChild.remove\b/lastChild.remove/g'
# skip matches in cpp and other wrong changes
hg revert mailnews/base/src/nsSubscribableServer.cpp
hg revert mailnews/base/src/nsSubscribableServer.h
hg revert mailnews/mime/src/mimemsig.cpp
hg revert mail/test/mozmill/composition/test-signature-updating.js
hg revert mail/test/mozmill/shared-modules/DOMHelpers.jsm
hg revert mailnews/addrbook/jsaddrbook/AddrBookMailingList.jsm
hg revert mailnews/addrbook/public/nsIAbDirectory.idl
hg revert mailnews/addrbook/test/unit/test_basic_nsIAbDirectory.js
hg revert mailnews/addrbook/test/unit/test_jsaddrbook.js
hg revert mailnews/addrbook/test/unit/test_mailList1.js
hg revert mailnews/addrbook/test/unit/test_uid.js
hg revert mailnews/compose/src/nsMsgCompose.cpp
hg revert mail/test/mozmill/cloudfile/test-cloudfile-attachment-urls.js
hg revert mail/test/mozmill/composition/test-forward-headers.js
hg revert calendar/import-export/calHtmlExport.js
hg revert mail/components/compose/content/cloudAttachmentLinkManager.js
hg revert mail/components/compose/content/dialogs/EdConvertToTable.js
hg revert mail/components/compose/content/dialogs/EdDialogCommon.js
hg revert mail/components/compose/content/dialogs/EdInsertTOC.js
hg revert mail/components/customizableui/CustomizeMode.jsm
hg revert mail/components/customizableui/PanelMultiView.jsm
hg revert mail/test/mozmill/shared-modules/ComposeHelpers.jsm
hg revert mailnews/addrbook/jsaddrbook/AddrBookDirectory.jsm
hg revert mailnews/base/util/JXON.js
hg revert mailnews/base/util/errUtils.js
hg revert mailnews/extensions/newsblog/content/feed-parser.js
hg revert mail/components/compose/texzilla/TeXZilla.js
../mach eslint --fix