u = up.util class up.HtmlParser constructor: (@html) -> @wrapNoscriptInHtml() @parsedDoc = u.createElementFromHtml(@html) title: -> @parsedDoc.querySelector("head title")?.textContent first: (selector) -> # Although we cannot have a jQuery collection from an entire HTML document, # we can use jQuery's Sizzle engine to grep through a DOM tree. # jQuery.find is the Sizzle function (https://github.com/jquery/sizzle/wiki#public-api) # which gives us non-standard CSS selectors such as `:has`. # It returns an array of DOM elements, not a jQuery collection. if match = $.find(selector, @parsedDoc)[0] return $(match) prepareForInsertion: ($element) -> element = $element[0] @unwrapNoscriptInElement(element) $(element) wrapNoscriptInHtml: -> # We wrap