-
Notifications
You must be signed in to change notification settings - Fork 162
feat: add clear command
#611
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
Draft
zyriab
wants to merge
25
commits into
bigskysoftware:dev
Choose a base branch
from
zyriab:feat/add-clear-command
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 11 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
d470ff3
docs: add `clear` command docs page
zyriab 70de59f
feat: add `clear` command
zyriab e24473e
chore: add `clear` tests
zyriab cf51993
chore: add `clear` test to test suite
zyriab ac58dd4
chore: rebuild
zyriab 6ea272b
chore: refactor test
zyriab 68a09ec
fix: properly clear targeted inner elements
zyriab c359735
chore: rename test
zyriab 509628c
chore: replace old test
zyriab 0f96b8e
chore: rebuild dist
zyriab db101ba
feat: add `clear` command to the rc files
zyriab 5ae641d
chore: remove console log
zyriab fcc0b33
feat(wip): use `in` instead of `from`
zyriab 878a756
chore(wip): add tests
zyriab d4a5f18
docs: add example
zyriab 6068c32
chore: add todo for later
zyriab 274e74a
exp(wip): added array clearing + `clear()` method calling + trying to…
zyriab 6e16bec
feat: add clearing of value proprety
zyriab d781a6f
feat(command-clear): add support for array and objects w/ `clear()` +…
zyriab ae3dc54
chore: remove console logs
zyriab b646bf5
chore: remove old log
zyriab a485b5c
feat: add test
zyriab f39e6e5
feat: add form clearing
zyriab dcc54cd
chore: format
zyriab eda2860
chore: refactor
zyriab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains hidden or 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 hidden or 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,58 @@ | ||
| describe("the clear command", function () { | ||
| beforeEach(function () { | ||
| clearWorkArea(); | ||
| }); | ||
| afterEach(function () { | ||
| clearWorkArea(); | ||
| }); | ||
|
|
||
| it("can clear inner text", function () { | ||
| var div = make("<div _='on click clear me'>foo</div>"); | ||
| div.innerHTML.should.equal("foo") | ||
| div.click(); | ||
| div.innerHTML.should.equal("") | ||
| }); | ||
|
|
||
| it("can clear other inner text", function () { | ||
| var div = make("<div _='on click clear #that'></div>"); | ||
| var div2 = make("<div id='that'>foo</div>"); | ||
| div2.innerHTML.should.equal("foo") | ||
| div.click(); | ||
| div2.innerHTML.should.equal("") | ||
| }); | ||
|
|
||
| it("can clear elements", function () { | ||
| var div = make("<div _='on click clear me'><p>foo</p></div>"); | ||
| div.innerHTML.should.equal("<p>foo</p>") | ||
| div.click(); | ||
| div.innerHTML.should.equal("") | ||
| }); | ||
|
|
||
| it("can clear other elements", function () { | ||
| var div = make("<div _='on click clear #that'></div>"); | ||
| var div2 = make("<div id='that'><p>foo</p></div>"); | ||
| div2.innerHTML.should.equal("<p>foo</p>") | ||
| div.click(); | ||
| div2.innerHTML.should.equal("") | ||
| }); | ||
|
|
||
| it("can clear parent element", function () { | ||
| var div = make("<div id='p1'><button id='b1' _='on click clear my.parentElement'></button></div> "); | ||
| var btn = byId("b1"); | ||
| div.childElementCount.should.equal(1) | ||
| btn.click(); | ||
| div.childElementCount.should.equal(0) | ||
| }); | ||
|
|
||
| it("can clear specific things", function () { | ||
| var div = make("<div><div id='d1' _='on click clear <p/>'><p>foo</p>bar</div><p>doh</p></div>"); | ||
| var d1 = byId('d1'); | ||
| div.innerHTML.includes("foo").should.equal(true); | ||
| div.innerHTML.includes("bar").should.equal(true); | ||
| div.innerHTML.includes("doh").should.equal(true); | ||
| d1.click(); | ||
| div.innerHTML.includes("foo").should.equal(false); | ||
| div.innerHTML.includes("bar").should.equal(true); | ||
| div.innerHTML.includes("doh").should.equal(true); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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,32 @@ | ||
| --- | ||
| title: clear - ///_hyperscript | ||
| --- | ||
|
|
||
| ## The `clear` Command | ||
|
|
||
| ### Syntax | ||
|
|
||
| ```ebnf | ||
| clear <expression> [from <expression>] | ||
| ``` | ||
|
|
||
| ### Description | ||
|
|
||
| The `clear` command allows you to clear an element's children or content. | ||
|
|
||
| ### Examples | ||
|
|
||
| ```html | ||
| <div _="on click clear me">Clear Me!</div> | ||
|
|
||
| <div _="on click clear the first <span/>">Clear This <span>Span</span> Content!</div> | ||
|
|
||
| <div _="on click clear <p/>"> | ||
| Clear <p>This</p> <span>Not This</span> <p>This Too</p>! | ||
| </div> | ||
|
|
||
| <div _="on click clear #another-div"> | ||
| Clear Another Div! | ||
| </div> | ||
|
|
||
| ``` |
This file contains hidden or 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 hidden or 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,58 @@ | ||
| describe("the clear command", function () { | ||
| beforeEach(function () { | ||
| clearWorkArea(); | ||
| }); | ||
| afterEach(function () { | ||
| clearWorkArea(); | ||
| }); | ||
|
|
||
| it("can clear inner text", function () { | ||
| var div = make("<div _='on click clear me'>foo</div>"); | ||
| div.innerHTML.should.equal("foo") | ||
| div.click(); | ||
| div.innerHTML.should.equal("") | ||
| }); | ||
|
|
||
| it("can clear other inner text", function () { | ||
| var div = make("<div _='on click clear #that'></div>"); | ||
| var div2 = make("<div id='that'>foo</div>"); | ||
| div2.innerHTML.should.equal("foo") | ||
| div.click(); | ||
| div2.innerHTML.should.equal("") | ||
| }); | ||
|
|
||
| it("can clear elements", function () { | ||
| var div = make("<div _='on click clear me'><p>foo</p></div>"); | ||
| div.innerHTML.should.equal("<p>foo</p>") | ||
| div.click(); | ||
| div.innerHTML.should.equal("") | ||
| }); | ||
|
|
||
| it("can clear other elements", function () { | ||
| var div = make("<div _='on click clear #that'></div>"); | ||
| var div2 = make("<div id='that'><p>foo</p></div>"); | ||
| div2.innerHTML.should.equal("<p>foo</p>") | ||
| div.click(); | ||
| div2.innerHTML.should.equal("") | ||
| }); | ||
|
|
||
| it("can clear parent element", function () { | ||
| var div = make("<div id='p1'><button id='b1' _='on click clear my.parentElement'></button></div> "); | ||
| var btn = byId("b1"); | ||
| div.childElementCount.should.equal(1) | ||
| btn.click(); | ||
| div.childElementCount.should.equal(0) | ||
| }); | ||
|
|
||
| it("can clear specific things", function () { | ||
| var div = make("<div><div id='d1' _='on click clear <p/>'><p>foo</p>bar</div><p>doh</p></div>"); | ||
| var d1 = byId('d1'); | ||
| div.innerHTML.includes("foo").should.equal(true); | ||
| div.innerHTML.includes("bar").should.equal(true); | ||
| div.innerHTML.includes("doh").should.equal(true); | ||
| d1.click(); | ||
| div.innerHTML.includes("foo").should.equal(false); | ||
| div.innerHTML.includes("bar").should.equal(true); | ||
| div.innerHTML.includes("doh").should.equal(true); | ||
| }); | ||
| }); |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it's the right approach but that the only way I've found for the last test to pass.
Otherwise it would clear all
elements, even from the caller's parent.