Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cable_ready

Package Overview
Dependencies
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cable_ready - npm Package Compare versions

Comparing version 5.0.0-pre7 to 5.0.0-pre8

.github_changelog_generator

54

CHANGELOG.md
# Changelog
## [v5.0.0.pre7](https://github.com/stimulusreflex/cable_ready/tree/v5.0.0.pre7) (2021-10-26)
[Full Changelog](https://github.com/stimulusreflex/cable_ready/compare/v5.0.0.pre6...v5.0.0.pre7)
**Merged pull requests:**
- Add custom header to fetch [\#159](https://github.com/stimulusreflex/cable_ready/pull/159) ([julianrubisch](https://github.com/julianrubisch))
## [v5.0.0.pre6](https://github.com/stimulusreflex/cable_ready/tree/v5.0.0.pre6) (2021-10-14)
[Full Changelog](https://github.com/stimulusreflex/cable_ready/compare/v5.0.0.pre5...v5.0.0.pre6)
**Merged pull requests:**
- Re-export consumer [\#158](https://github.com/stimulusreflex/cable_ready/pull/158) ([julianrubisch](https://github.com/julianrubisch))
- Consolidate elements into a base class [\#157](https://github.com/stimulusreflex/cable_ready/pull/157) ([julianrubisch](https://github.com/julianrubisch))
## [v5.0.0.pre5](https://github.com/stimulusreflex/cable_ready/tree/v5.0.0.pre5) (2021-10-07)
[Full Changelog](https://github.com/stimulusreflex/cable_ready/compare/v5.0.0.pre4...v5.0.0.pre5)
**Implemented enhancements:**
- error handling for updates\_for edge cases [\#155](https://github.com/stimulusreflex/cable_ready/pull/155) ([leastbad](https://github.com/leastbad))
- post-pre4 updates [\#154](https://github.com/stimulusreflex/cable_ready/pull/154) ([leastbad](https://github.com/leastbad))
**Fixed bugs:**
- Given multiple updates\_for blocks with custom urls, only the first is re-fetched [\#153](https://github.com/stimulusreflex/cable_ready/issues/153)
**Merged pull requests:**
- Export elements [\#156](https://github.com/stimulusreflex/cable_ready/pull/156) ([julianrubisch](https://github.com/julianrubisch))
## [v5.0.0.pre4](https://github.com/stimulusreflex/cable_ready/tree/v5.0.0.pre4) (2021-10-01)
[Full Changelog](https://github.com/stimulusreflex/cable_ready/compare/v5.0.0.pre3...v5.0.0.pre4)
**Implemented enhancements:**
- Receive morph updates from model/PORO callbacks [\#145](https://github.com/stimulusreflex/cable_ready/pull/145) ([leastbad](https://github.com/leastbad))
**Closed issues:**
- Uncaught TypeError: operations.forEach is not a function [\#149](https://github.com/stimulusreflex/cable_ready/issues/149)
**Merged pull requests:**
- Optionally debounce updates [\#151](https://github.com/stimulusreflex/cable_ready/pull/151) ([julianrubisch](https://github.com/julianrubisch))
- Fix updates for lazy loading [\#150](https://github.com/stimulusreflex/cable_ready/pull/150) ([julianrubisch](https://github.com/julianrubisch))
- Bump nokogiri from 1.12.3 to 1.12.5 [\#148](https://github.com/stimulusreflex/cable_ready/pull/148) ([dependabot[bot]](https://github.com/apps/dependabot))
- \[Readme\] Make badges link to RubyGems and npm packages [\#147](https://github.com/stimulusreflex/cable_ready/pull/147) ([palkan](https://github.com/palkan))
- Fix wrong CableReady import [\#146](https://github.com/stimulusreflex/cable_ready/pull/146) ([n-rodriguez](https://github.com/n-rodriguez))
## [v5.0.0.pre3](https://github.com/stimulusreflex/cable_ready/tree/v5.0.0.pre3) (2021-08-22)

@@ -4,0 +58,0 @@

61

javascript/elements/updates_for_element.js

@@ -7,3 +7,3 @@ import morphdom from 'morphdom'

import activeElement from '../active_element'
import { debounce, assignFocus, dispatch, handleErrors } from '../utils'
import { debounce, assignFocus, dispatch, graciouslyFetch } from '../utils'

@@ -44,3 +44,3 @@ const template = `

async update () {
async update (data) {
const identifier = this.getAttribute('identifier')

@@ -51,2 +51,10 @@ const query = `updates-for[identifier="${identifier}"]`

const only = this.getAttribute('only')
if (
only &&
data.changed &&
!only.split(' ').some(attribute => data.changed.includes(attribute))
)
return
const html = {}

@@ -59,10 +67,5 @@ const template = document.createElement('template')

if (!html.hasOwnProperty(url(blocks[i]))) {
const response = await fetch(url(blocks[i]), {
headers: {
'X-Cable-Ready': 'update'
}
const response = await graciouslyFetch(url(blocks[i]), {
'X-Cable-Ready': 'update'
})
.then(handleErrors)
.catch(e => console.error(`Could not fetch ${url(blocks[i])}`))
if (response === undefined) return
html[url(blocks[i])] = await response.text()

@@ -72,2 +75,5 @@ }

template.innerHTML = String(html[url(blocks[i])]).trim()
await this.resolveTurboFrames(template.content)
const fragments = template.content.querySelectorAll(query)

@@ -99,2 +105,39 @@

async resolveTurboFrames (documentFragment) {
const reloadingTurboFrames = [
...documentFragment.querySelectorAll(
'turbo-frame[src]:not([loading="lazy"])'
)
]
return Promise.all(
reloadingTurboFrames.map(frame => {
return new Promise(async resolve => {
const frameResponse = await graciouslyFetch(
frame.getAttribute('src'),
{
'Turbo-Frame': frame.id,
'X-Cable-Ready': 'update'
}
)
const frameTemplate = document.createElement('template')
frameTemplate.innerHTML = await frameResponse.text()
// recurse here to get all nested eager loaded frames
await this.resolveTurboFrames(frameTemplate.content)
documentFragment.querySelector(
`turbo-frame#${frame.id}`
).innerHTML = String(
frameTemplate.content.querySelector(`turbo-frame#${frame.id}`)
.innerHTML
).trim()
resolve()
})
})
)
}
get debounce () {

@@ -101,0 +144,0 @@ return this.hasAttribute('debounce')

@@ -0,1 +1,2 @@

import { version } from '../package.json'
import * as MorphCallbacks from './morph_callbacks'

@@ -27,2 +28,3 @@ import { shouldMorphCallbacks, didMorphCallbacks } from './morph_callbacks'

addOperations,
version,
get DOMOperations () {

@@ -29,0 +31,0 @@ console.warn(

@@ -117,2 +117,25 @@ import { inputTags, textInputTypes } from './enums'

// A proxy method to wrap a fetch call in error handling
//
// * url - the URL to fetch
// * additionalHeaders - an object of additional headers passed to fetch
//
async function graciouslyFetch (url, additionalHeaders) {
try {
const response = await fetch(url, {
headers: {
'X-REQUESTED-WITH': 'XmlHttpRequest',
...additionalHeaders
}
})
if (response == undefined) return
handleErrors(response)
return response
} catch (e) {
console.error(`Could not fetch ${url}`)
}
}
export {

@@ -129,3 +152,4 @@ isTextInput,

debounce,
handleErrors
handleErrors,
graciouslyFetch
}

2

package.json
{
"name": "cable_ready",
"version": "5.0.0-pre7",
"version": "5.0.0-pre8",
"description": "CableReady helps you create great real-time user experiences by making it simple to trigger client-side DOM changes from server-side Ruby.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -92,2 +92,3 @@ <p align="center">

1. Yarn will prompt you for the new version. Pre-release versions use `-preN`
1. Run `GITHUB_CHANGELOG_GENERATOR_TOKEN=SECRET rake changelog`
1. Commit and push changes to github

@@ -94,0 +95,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc