Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

dealt with the Node.lookupNamespaceURI(null) bug

  • Loading branch information...
commit eef9a8df479684d6ceaec78e6d5c575267c3c927 1 parent 9297523
xKerman xKerman authored
Showing with 20 additions and 5 deletions.
  1. +15 −2 data/autopagerize.user.js
  2. +5 −3 lib/main.js
17 data/autopagerize.user.js
View
@@ -304,7 +304,7 @@ AutoPager.prototype.addPage = function(htmlDoc, page) {
}
}
- if (page[0] && page[0].tagName == 'TR') {
+ if (page[0] && page[0].tagName.toLowerCase() == 'tr') {
var insertParent = this.insertPoint.parentNode
var colNodes = getElementsByXPath('child::tr[1]/child::*[self::td or self::th]', insertParent)
@@ -525,7 +525,20 @@ function getXPathResult(xpath, node, resultType) {
var doc = node.ownerDocument || node
var resolver = doc.createNSResolver(node.documentElement || node)
// Use |node.lookupNamespaceURI('')| for Opera 9.5
- var defaultNS = node.lookupNamespaceURI(null)
+ // A workaround for bugs of Node.lookupNamespaceURI(null)
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=693615
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=694754
+ var defaultNS = null
+ try {
+ // This follows the spec: http://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespaceURIAlgo
+ if (node.nodeType == node.DOCUMENT_NODE) {
+ defaultNS = node.documentElement.lookupNamespaceURI(null)
+ }
+ else {
+ defaultNS = node.lookupNamespaceURI(null)
+ }
+ }
+ catch(e) {}
if (defaultNS) {
const defaultPrefix = '__default__'
8 lib/main.js
View
@@ -56,15 +56,17 @@ exports.main = function (options, callbacks) {
pageMod.PageMod({
include: ['http://*', 'https://*'],
contentScriptWhen: 'ready',
- contentScript: self.data.load('extension.js') + ';' +
- self.data.load('autopagerize.user.js'),
+ contentScriptFile: [
+ self.data.url('extension.js'),
+ self.data.url('autopagerize.user.js')
+ ],
onAttach: onAttach
})
contextMenu.Menu({
label: "AutoPagerize",
context: contextMenu.PageContext(),
- contentScript: self.data.load('context_menu.js'),
+ contentScriptFile: self.data.url('context_menu.js'),
items: [
contextMenu.Item({ label: "on/off", data: "toggle" }),
contextMenu.Item({ label: "config", data: "config" })
Please sign in to comment.
Something went wrong with that request. Please try again.