Skip to content

Commit

Permalink
Added typedefs, better web-components support & more
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianFun123 committed Mar 1, 2024
1 parent af93d28 commit 4af774e
Show file tree
Hide file tree
Showing 10 changed files with 485 additions and 98 deletions.
Binary file added .DS_Store
Binary file not shown.
489 changes: 415 additions & 74 deletions JDOM.js

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# JDOM `2.0.2`
# JDOM `2.1.0`
# A wrapper for query selector and html elements

## Install
Expand All @@ -25,8 +25,8 @@ el.css({
background: '#000000'
})

el.each(el => {
console.log($(el).html())
el.each($el => {
console.log(el.html())
})

el.text('Hello world')
Expand Down Expand Up @@ -84,11 +84,16 @@ $('#app').append(

<script>
// Create HTMLElement
const MyComponent = $c(c => {
c.text('Hello World')
c.click(() => {
alert('Hey')
})
const MyComponent = $c((c, self) => {
c.append(
$n('span')
.text('Hello World')
.click(() => {
alert('Hey')
})
)
self.addStyle(`span { color: red }`)
})
// Register component
Expand Down
2 changes: 1 addition & 1 deletion dist/jdom.js

Large diffs are not rendered by default.

27 changes: 21 additions & 6 deletions example.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<title>Document</title>
</head>
<body>
<!-- <h1 id="ney"></h1>
<div id="app">
<h1 id="hay"></h1>
</div> -->
<my-element my-attr="Hey" class="btn-primary"></my-element>
</div>

<my-app></my-app>
</body>
</html>

Expand All @@ -22,6 +22,10 @@ <h1 id="hay"></h1>

const app = $('#app')

$('asd').animate({
'test': 423
})


app.append(
$n('button')
Expand All @@ -33,6 +37,10 @@ <h1 id="hay"></h1>

app.animate({background: '#FF0022'}, 1000)

app.on('click', e => {

})

app.animator([
{
css: {
Expand All @@ -54,12 +62,19 @@ <h1 id="hay"></h1>
},
])

const HomePage = $c((el, self) => {
el.append($n('h1').text('Homepage'))

})

$r('my-element', $c(c => {
return c.append(c.attr('my-attr'))
}))
const MyApp = $c(el => {
el.append(new HomePage())
el.append($n('home-page'))
})


$r('home-page', HomePage)
$r('my-app', MyApp)

</script>
<style>
Expand Down
15 changes: 15 additions & 0 deletions html-typedefs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 16 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import _JDOM from './JDOM.js'

export const $ = el => new JDOM(el)
export const $n = el => JDOM.new(el)
export const $c = (tag, comp) => JDOM.component(tag, comp)
export const $r = (tag, comp) => JDOM.registerComponent(tag, comp)
export const $h = html => JDOM.fromHTML(html)

/**
* @param {HTMLElement|JDOM|NodeList|string} el
* @param {Element|parent} parent
* @return {_JDOM}
*/
export const $ = (el, parent = undefined) => new JDOM(el, parent)

/**
* @param {HTMLTag|string} tag
* @return {_JDOM}
*/
export const $n = _JDOM.new
export const $c = _JDOM.component
export const $r = _JDOM.registerComponent
export const $h = _JDOM.fromHTML
export const JDOM = _JDOM

export default {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jdomjs",
"version": "2.0.2",
"version": "2.1.0",
"description": "A wrapper for query selector and html elements",
"main": "JDOM.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion uppm.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jdom",
"version": "2.0.2",
"version": "2.0.3",
"description": "Javascript DOM-Selector",
"author": "InteraApps",
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path');
require("babel-polyfill")
module.exports = {
module.exports = [{
entry: ['babel-polyfill', './index.js'],
output: {
filename: 'jdom.js',
Expand All @@ -24,4 +24,4 @@ module.exports = {
]
}

};
}];

0 comments on commit 4af774e

Please sign in to comment.