Skip to content

Commit cd19357

Browse files
committed
[Breaking] Add setData method and rename data method to getData
1 parent a6c87e3 commit cd19357

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "modujs",
3-
"version": "1.2.4",
3+
"version": "1.3.0",
44
"description": "Dead simple modular JavaScript framework for ES modules.",
55
"repository": "modularorg/modularjs",
66
"author": "Antoine Boulanger <hello@antoineboulanger.com> (https://antoineboulanger.com)",

readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ export {default as example} from './modules/example';
7474
| ------ | ----------- | ------- |
7575
| `this.$('query'[, 'context'])` | Module scoped query selector. | `this.$('dropdown', e.currentTarget)` |
7676
| `this.parent('name', 'context')` | Module scoped parent selector. | `this.parent('item', e.currentTarget)` |
77-
| `this.data('name'[, 'context'])` | Get module or target data attribute. | `this.data('name', e.currentTarget)` |
7877
| `this.call('function', arg, 'module'[, 'id'])` | Call another module method. | `this.call('scrollTo', section, 'scroll', 'main')` |
78+
| `this.getData('name'[, 'context'])` | Get module or target data attribute. | `this.getData('name', e.currentTarget)` |
79+
| `this.setData('name', 'value'[, 'context'])` | Set module or target data attribute. | `this.setData('name', 'value', e.currentTarget)` |
7980

8081
## Custom methods
8182
| Method | Description |

src/module.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,16 @@ export default class {
112112
}
113113
}
114114

115-
data(name, context) {
115+
getData(name, context) {
116116
const target = context || this.el;
117117
return target.getAttribute(this.mAttr + '-' + name);
118118
}
119119

120+
setData(name, value, context) {
121+
const target = context || this.el;
122+
return target.setAttribute(this.mAttr + '-' + name, value);
123+
}
124+
120125
call(func, args, mod, id) {
121126
if (args && !mod) {
122127
mod = args;

0 commit comments

Comments
 (0)