How to use the thug.DOM.W3C.Core.DOMImplementation.DOMImplementation function in thug

To help you get started, we’ve selected a few thug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github buffer / thug / thug / DOM / W3C / Core / Document.py View on Github external
def createElement(self, tagname, tagvalue = None):
        from .DOMImplementation import DOMImplementation

        if log.ThugOpts.features_logging:
            log.ThugLogging.Features.increase_createelement_count()

        # Internet Explorer 8 and below also support the syntax
        # document.createElement('<p>')
        if log.ThugOpts.Personality.isIE() and log.ThugOpts.Personality.browserMajorVersion &lt; 9:
            if tagname.startswith('&lt;') and '&gt;' in tagname:
                tagname = tagname[1:].split('&gt;')[0]

        return DOMImplementation.createHTMLElement(self, bs4.Tag(parser = self.doc, name = tagname))
</p>
github buffer / thug / thug / DOM / W3C / Core / Element.py View on Github external
def _querySelector(self, selectors):
        from .DOMImplementation import DOMImplementation

        try:
            s = self.tag.select(selectors)
        except Exception: # pragma: no cover
            return None

        return DOMImplementation.createHTMLElement(self, s[0]) if s and s[0] else None
github buffer / thug / thug / DOM / W3C / HTML / HTMLFormElement.py View on Github external
def elements(self):
        from thug.DOM.W3C.Core.DOMImplementation import DOMImplementation

        nodes = []
        for tag in self.tag.children:
            if getattr(tag, 'name', None) and tag.name not in ('br', ):
                nodes.append(DOMImplementation.createHTMLElement(self.doc, tag))

        return HTMLFormControlsCollection(self.doc, nodes)
github buffer / thug / thug / DOM / Window.py View on Github external
def frames(self):
        """an array of all the frames (including iframes) in the current window"""
        from thug.DOM.W3C.HTML.HTMLCollection import HTMLCollection

        frames = set()
        for frame in self._findAll(['frame', 'iframe']):
            if not getattr(frame, '_node', None):
                from thug.DOM.W3C.Core.DOMImplementation import DOMImplementation
                DOMImplementation.createHTMLElement(self.window.doc, frame)

            frames.add(frame._node)

        return HTMLCollection(self.doc, list(frames))
github buffer / thug / thug / DOM / W3C / HTML / HTMLFormElement.py View on Github external
def __getattr__(self, key):
        for tag in self.tag.children:
            if tag.name not in ('input', ):
                continue

            if 'name' in tag.attrs and tag.attrs['name'] in (key, ):
                from thug.DOM.W3C.Core.DOMImplementation import DOMImplementation
                return DOMImplementation.createHTMLElement(self.doc, tag)

        raise AttributeError
github buffer / thug / thug / DOM / W3C / Core / DocumentFragment.py View on Github external
def _querySelector(self, selectors):
        from .DOMImplementation import DOMImplementation

        try:
            s = self.tag.select(selectors)
        except Exception: # pragma: no cover
            return None

        return DOMImplementation.createHTMLElement(self, s[0]) if s and s[0] else None
github buffer / thug / thug / DOM / W3C / Core / DOMImplementation.py View on Github external
def hasFeature(feature, version):
        if version == "":
            version = None

        return (feature.lower(), version) in DOMImplementation.features
github buffer / thug / thug / DOM / W3C / Core / Document.py View on Github external
def _querySelector(self, selectors):
        from .DOMImplementation import DOMImplementation

        try:
            s = self.doc.select(selectors)
        except Exception: # pragma: no cover
            return None

        return DOMImplementation.createHTMLElement(self, s[0]) if s and s[0] else None
github buffer / thug / thug / DOM / W3C / HTML / HTMLDocument.py View on Github external
if self._win and getattr(self._win, "doc", None):
            if attr in self._win.doc.DFT.handled_on_events:
                return None

            if attr in self._win.doc.DFT._on_events:
                return None

        _attr = self.getElementById(attr)
        if _attr:
            return _attr

        _attr = self.getElementsByName(attr)
        if _attr:
            from thug.DOM.W3C.Core.DOMImplementation import DOMImplementation
            return DOMImplementation.createHTMLElement(self.doc, _attr[0])

        log.info("[HTMLDocument] Undefined: %s", attr)
        raise AttributeError
github buffer / thug / thug / DOM / W3C / w3c.py View on Github external
def getDOMImplementation(dom = None, **kwds):
    from thug.DOM.W3C.Core.DOMImplementation import DOMImplementation

    return DOMImplementation(dom if dom else bs4.BeautifulSoup('', 'lxml'), **kwds)