Divmod.Runtime.SelectorSupportingPlatform = Divmod.Runtime.Platform.subclass(
    'Divmod.Runtime.SelectorSupportingPlatform');
Divmod.Runtime.SelectorSupportingPlatform.methods(
    function getElementsByTagNameShallow(self, root, tagName) {
        tagName = tagName.replace(/\:/g, "|");
        return root.querySelectorAll(tagName, Divmod.Runtime._nsResolver);
    },

    function _selectorQuery(self, root, attrName, attrValue, /* optional */ all) {
        attrName = attrName.replace(/\:/g, "|");
        if (all === undefined) {
            all = false;
        }
        if (all) {
            return root.querySelectorAll('*['+attrName+'="'+attrValue+'"]', Divmod.Runtime._nsResolver);
        } else {
            return root.querySelector('*['+attrName+'="'+attrValue+'"]', Divmod.Runtime._nsResolver);
        }
    },

    function firstNodeByAttribute(self, root, attrName, attrValue) {
        /* duplicate this here rather than adding an "onlyOne" arg to
           nodesByAttribute so adding an extra arg accidentally doesn't change
           it's behaviour if called directly
        */
        var node = self._selectorQuery(root, attrName, attrValue)
        if (!node) {
            throw Divmod.Runtime.NodeAttributeError(root, attrName, attrValue);
        }
        return node;
    },

    function nodeByAttribute(self, root, attrName, attrValue, /* optional */ defaultNode){
        var nodes = self._selectorQuery(root, attrName, attrValue, true);
        if (nodes.length > 1) {
            throw new Error("Found too many " + attrName + " = " + attrValue);
        }
        else if (nodes.length < 1) {
            if (defaultNode === undefined) {
                throw Divmod.Runtime.NodeAttributeError(root, attrName, attrValue);
            }
            else {
                return defaultNode;
            }
        }
        else {
            var result = nodes[0];
            return result;
        }
    },

    function nodesByAttribute(self, root, attrName, attrValue) {
        var nodes = self._selectorQuery(root, attrName, attrValue, true);
        return nodes;
    });
jethro@divmod.org