-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from Shopify/rm-decaffeinate
Remove coffeescript from this library
- Loading branch information
Showing
57 changed files
with
4,342 additions
and
3,619 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake | ||
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby | ||
|
||
name: Build | ||
|
||
on: [push, pull_request] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.2' | ||
bundler-cache: true | ||
- name: Setup Firefox | ||
uses: browser-actions/[email protected] | ||
- name: Setup Geckodriver | ||
uses: browser-actions/[email protected] | ||
- name: Start xvfb | ||
run: /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & | ||
- name: Run tests | ||
run: bundle exec rake ci | ||
env: | ||
DISPLAY: ":99.0" | ||
DRIVER: "selenium" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//= require_self | ||
//= require_tree ./turbograft | ||
|
||
if (window.TurboGraft == null) { window.TurboGraft = { handlers: {} }; } | ||
|
||
TurboGraft.tgAttribute = function(attr) { | ||
if (attr.slice(0, 3) === 'tg-') { | ||
return `data-${attr}`; | ||
} else { | ||
return `data-tg-${attr}`; | ||
} | ||
}; | ||
|
||
TurboGraft.getTGAttribute = function(node, attr) { | ||
const tgAttr = TurboGraft.tgAttribute(attr); | ||
return node.getAttribute(tgAttr) || node.getAttribute(attr); | ||
}; | ||
|
||
TurboGraft.removeTGAttribute = function(node, attr) { | ||
const tgAttr = TurboGraft.tgAttribute(attr); | ||
node.removeAttribute(tgAttr); | ||
node.removeAttribute(attr); | ||
}; | ||
|
||
TurboGraft.hasTGAttribute = function(node, attr) { | ||
const tgAttr = TurboGraft.tgAttribute(attr); | ||
return node.hasAttribute(tgAttr) || node.hasAttribute(attr); | ||
}; | ||
|
||
TurboGraft.querySelectorAllTGAttribute = function(node, attr, value = null) { | ||
const tgAttr = TurboGraft.tgAttribute(attr); | ||
if (value) { | ||
return node.querySelectorAll(`[${tgAttr}=${value}], [${attr}=${value}]`); | ||
} else { | ||
return node.querySelectorAll(`[${tgAttr}], [${attr}]`); | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// The Click class handles clicked links, verifying if Turbolinks should | ||
// take control by inspecting both the event and the link. If it should, | ||
// the page change process is initiated. If not, control is passed back | ||
// to the browser for default functionality. | ||
window.Click = class Click { | ||
static installHandlerLast(event) { | ||
if (!event.defaultPrevented) { | ||
document.removeEventListener('click', Click.handle, false); | ||
document.addEventListener('click', Click.handle, false); | ||
} | ||
} | ||
|
||
static handle(event) { | ||
return new Click(event); | ||
} | ||
|
||
constructor(event) { | ||
this.event = event; | ||
if (this.event.defaultPrevented) { return; } | ||
this._extractLink(); | ||
if (this._validForTurbolinks()) { | ||
Turbolinks.visit(this.link.href); | ||
this.event.preventDefault(); | ||
} | ||
} | ||
|
||
_extractLink() { | ||
let link = this.event.target; | ||
while (!!link.parentNode && (link.nodeName !== 'A')) { link = link.parentNode; } | ||
if ((link.nodeName === 'A') && (link.href.length !== 0)) { this.link = new Link(link); } | ||
} | ||
|
||
_validForTurbolinks() { | ||
return (this.link != null) && !this.link.shouldIgnore() && !this._nonStandardClick(); | ||
} | ||
|
||
_nonStandardClick() { | ||
return (this.event.which > 1) || | ||
this.event.metaKey || | ||
this.event.ctrlKey || | ||
this.event.shiftKey || | ||
this.event.altKey; | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* The ComponentUrl class converts a basic URL string into an object | ||
* that behaves similarly to document.location. | ||
* | ||
* If an instance is created from a relative URL, the current document | ||
* is used to fill in the missing attributes (protocol, host, port). | ||
*/ | ||
window.ComponentUrl = class ComponentUrl { | ||
constructor(original, link) { | ||
if (original == null) { | ||
original = document.location.href; | ||
} | ||
if (link == null) { | ||
link = document.createElement('a'); | ||
} | ||
if (original.constructor === ComponentUrl) { | ||
return original; | ||
} | ||
this.original = original; | ||
this.link = link; | ||
this._parse(); | ||
} | ||
|
||
withoutHash() { | ||
return this.href.replace(this.hash, ''); | ||
}; | ||
|
||
// Intention revealing function alias | ||
withoutHashForIE10compatibility() { | ||
return this.withoutHash(); | ||
}; | ||
|
||
hasNoHash() { | ||
return this.hash.length === 0; | ||
}; | ||
|
||
_parse() { | ||
this.link.href = this.original; | ||
this.href = this.link.href; | ||
this.protocol = this.link.protocol; | ||
this.host = this.link.host; | ||
this.hostname = this.link.hostname | ||
this.port = this.link.port; | ||
this.pathname = this.link.pathname; | ||
this.search = this.link.search; | ||
this.hash = this.link.hash; | ||
this.origin = [this.protocol, '//', this.hostname].join(''); | ||
if (this.port.length !== 0) { | ||
this.origin += ":" + this.port; | ||
} | ||
this.relative = [this.pathname, this.search, this.hash].join(''); | ||
return this.absolute = this.href; | ||
}; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
window.CSRFToken = class CSRFToken { | ||
static get(doc) { | ||
if (!doc) { doc = document; } | ||
const tag = doc.querySelector('meta[name="csrf-token"]'); | ||
|
||
const object = { | ||
node: tag | ||
}; | ||
|
||
if (tag) { | ||
object.token = tag.getAttribute('content'); | ||
} | ||
|
||
return object; | ||
} | ||
|
||
static update(latest) { | ||
const current = this.get(); | ||
if ((current.token != null) && (latest != null) && (current.token !== latest)) { | ||
current.node.setAttribute('content', latest); | ||
} | ||
} | ||
}; |
Oops, something went wrong.