Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make morph a first class operation #4

Merged
merged 3 commits into from
Nov 3, 2017
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/pkg/
/spec/reports/
/tmp/
node_modules/
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ cable_ready["MyChannel"].dispatch_event(

### Element Mutations

#### [morph](https://github.com/patrick-steele-idem/morphdom)

Fast lightweight DOM diffing/patching without a virtual DOM.

```ruby
cable_ready["MyChannel"].morph(
selector: "string", # required - string containing one or more CSS selectors separated by commas
focusSelector: "string", # [null] - string containing one or more CSS selectors separated by commas
html: "string" # [null] - the HTML to assign
)
```

#### [innerHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML)

Sets the innerHTML of a DOM element.
Expand Down Expand Up @@ -226,6 +238,16 @@ cable_ready["MyChannel"].set_dataset_property(
)
```

## JavaScript Development

The JavaScript source is located in `vendor/assets/javascripts/cable_ready/src`
& transpiles to `vendor/assets/javascripts/cable_ready/cable_ready.js` via Webpack.

```sh
cd vendor/assets/javascripts/cable_ready/src
webpack
```

---

<a target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/QMSjMHrtPhvfmCnk5Hbikhhr/hopsoft/cable_ready'>
Expand Down
2 changes: 1 addition & 1 deletion cable_ready.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
gem.homepage = "https://github.com/hopsoft/cable_ready"
gem.summary = "put something here"

gem.files = Dir["lib/**/*.rb", "vendor/**/*", "bin/*", "[A-Z]*"]
gem.files = Dir["lib/**/*.rb", "vendor/assets/javascripts/cable_ready.js", "bin/*", "[A-Z]*"]
gem.test_files = Dir["test/**/*.rb"]

gem.add_dependency "activesupport", ">= 5.0.0"
Expand Down
39 changes: 22 additions & 17 deletions lib/cable_ready/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ def dispatch_event(options={})
operations[:dispatch_event] << options
end

def morph(options={})
operations[:morph] << options
end

def inner_html(options={})
operations[:inner_html] << options
end
Expand Down Expand Up @@ -158,22 +162,23 @@ def set_dataset_property(options={})

private

def stub
{
dispatch_event: [],
inner_html: [],
text_content: [],
insert_adjacent_html: [],
insert_adjacent_text: [],
remove: [],
replace: [],
set_value: [],
set_attribute: [],
remove_attribute: [],
add_css_class: [],
remove_css_class: [],
set_dataset_property: []
}
end
def stub
{
dispatch_event: [],
morph: [],
inner_html: [],
text_content: [],
insert_adjacent_html: [],
insert_adjacent_text: [],
remove: [],
replace: [],
set_value: [],
set_attribute: [],
remove_attribute: [],
add_css_class: [],
remove_css_class: [],
set_dataset_property: []
}
end
end
end
2 changes: 1 addition & 1 deletion lib/cable_ready/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module CableReady
VERSION = "2.0.1"
VERSION = "2.0.2"
end
Loading