JezK
Edit File: snapshot.js
// Generated by CoffeeScript 2.7.0 (function() { require('./head_details'); Turbolinks.Snapshot = class Snapshot { static wrap(value) { if (value instanceof this) { return value; } else if (typeof value === "string") { return this.fromHTMLString(value); } else { return this.fromHTMLElement(value); } } static fromHTMLString(html) { var htmlElement; htmlElement = document.createElement("html"); htmlElement.innerHTML = html; return this.fromHTMLElement(htmlElement); } static fromHTMLElement(htmlElement) { var bodyElement, headDetails, headElement, ref; headElement = htmlElement.querySelector("head"); bodyElement = (ref = htmlElement.querySelector("body")) != null ? ref : document.createElement("body"); headDetails = Turbolinks.HeadDetails.fromHeadElement(headElement); return new this(headDetails, bodyElement); } constructor(headDetails1, bodyElement1) { this.headDetails = headDetails1; this.bodyElement = bodyElement1; } clone() { return new this.constructor(this.headDetails, this.bodyElement.cloneNode(true)); } getRootLocation() { var ref, root; root = (ref = this.getSetting("root")) != null ? ref : "/"; return new Turbolinks.Location(root); } getCacheControlValue() { return this.getSetting("cache-control"); } getElementForAnchor(anchor) { try { return this.bodyElement.querySelector(`[id='${anchor}'], a[name='${anchor}']`); } catch (error) {} } getPermanentElements() { return this.bodyElement.querySelectorAll("[id][data-turbolinks-permanent]"); } getPermanentElementById(id) { return this.bodyElement.querySelector(`#${id}[data-turbolinks-permanent]`); } getPermanentElementsPresentInSnapshot(snapshot) { var element, i, len, ref, results; ref = this.getPermanentElements(); results = []; for (i = 0, len = ref.length; i < len; i++) { element = ref[i]; if (snapshot.getPermanentElementById(element.id)) { results.push(element); } } return results; } findFirstAutofocusableElement() { return this.bodyElement.querySelector("[autofocus]"); } hasAnchor(anchor) { return this.getElementForAnchor(anchor) != null; } isPreviewable() { return this.getCacheControlValue() !== "no-preview"; } isCacheable() { return this.getCacheControlValue() !== "no-cache"; } isVisitable() { return this.getSetting("visit-control") !== "reload"; } // Private getSetting(name) { return this.headDetails.getMetaValue(`turbolinks-${name}`); } }; }).call(this);