Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/assets/javascripts/turbo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4943,7 +4943,18 @@ function walk(obj) {
}), {});
}

const template = Object.assign(document.createElement("template"), {
innerHTML: "<style>:host { display: none; }</style>"
});

class TurboCableStreamSourceElement extends HTMLElement {
constructor() {
super();
this.attachShadow({
mode: "open"
});
this.shadowRoot.appendChild(template.content.cloneNode(true));
}
async connectedCallback() {
connectStreamSource(this);
this.subscription = await subscribeTo(this.channel, {
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/turbo.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/assets/javascripts/turbo.min.js.map

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions app/javascript/turbo/cable_stream_source_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@ import { connectStreamSource, disconnectStreamSource } from "@hotwired/turbo"
import { subscribeTo } from "./cable"
import snakeize from "./snakeize"

const template = Object.assign(document.createElement("template"), {
innerHTML: "<style>:host { display: none; }</style>"
})

class TurboCableStreamSourceElement extends HTMLElement {
constructor() {
super()

this.attachShadow({ mode: "open" })
this.shadowRoot.appendChild(template.content.cloneNode(true))
}

async connectedCallback() {
connectStreamSource(this)
this.subscription = await subscribeTo(this.channel, {
Expand Down
2 changes: 1 addition & 1 deletion test/system/broadcasts_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class BroadcastsTest < ApplicationSystemTestCase
private

def wait_for_stream_to_be_connected
assert_selector "turbo-cable-stream-source[connected]", visible: false
assert_selector "turbo-cable-stream-source[connected]", visible: false, style: { display: "none" }
end

def assert_broadcasts_text(text, to:, &block)
Expand Down