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

Prepend and other html manipulations #25

Closed
dy opened this issue Jun 18, 2019 · 4 comments
Closed

Prepend and other html manipulations #25

dy opened this issue Jun 18, 2019 · 4 comments
Labels
research Decision-making, arguments, discussion, comparison, design

Comments

@dy
Copy link
Owner

dy commented Jun 18, 2019

How to prepend some content?

As a modifier
$`<aspect sel="some-selector" prepend=${content}/>` -adds functional-ish aspect -not-position-based

As a content placeholder
$`<aspect sel=".some-selector">${content}<parentNode.children></>` - prop access in tagname

Direct way
$`<aspect sel=".some-selector">${content}${el => el.childNodes}</>` - breaks html

HTML-way
<aspect sel=".some-selector"><i></i><slot children/></aspect> + logically meaningful slot application
@dy

This comment has been minimized.

@dy dy closed this as completed Jun 20, 2019
@dy
Copy link
Owner Author

dy commented Jun 21, 2019

The question of adding content is relevant, see https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML.
There are 4 ways we may want to insert the html:

html('#el:beforebegin', code)
html('#el:afterbegin', code)
html('#el:beforeend', code)
html('#el:afterend', code)

but these aren't much useful for non-selector element, or that will be a shallow pseudo html(':beforebegin', code). In fact, these pseudos are redundant, it's enough to have just two: before and after. But - besides - that is too custom selector. Also - unclear how to order children.
Should be hooks-like well-established mechanism.

@dy dy reopened this Jun 21, 2019
@dy
Copy link
Owner Author

dy commented Jun 22, 2019

! it must be as natural and full-featured as reducers. How?!
{a: 1, b: 2, c, children: {x}, parent, ...rest} === <a=1 b=2 c ...rest><x></a>
[{a}, {b}, {c}, ...rest] === <a><b><c><...rest>?

// rough doodle
state => {a: 1, ...state}
state => <a=1 ...state/>
[a, b, c] === <><a><b><c></>

<...rest> is possible only for main-aspect elements to define spread of main reality aspect. But in fact that is <children=...elements>-like. So.

What's the name of rest spread for html elements?
. Fragment === collection of elements. Array === collection of elements.

wrapping: <div><...></div>
prepending: <div/><...>
appending: <...><div>

That is INCREDIBLY elegant, very similar to react's fragment tag.

How to pick nodes from html by name / index?

// insert element by the placeholder like that.
<div><#abc><x><...></div>

OMG. That is rediscovery. HMTL reducers.

@dy
Copy link
Owner Author

dy commented Jun 23, 2019

Noble. Good.

@dy dy closed this as completed Jun 23, 2019
@dy dy added the research Decision-making, arguments, discussion, comparison, design label Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
research Decision-making, arguments, discussion, comparison, design
Projects
None yet
Development

No branches or pull requests

1 participant