Skip to content

Commit

Permalink
version bump, got rid of all the datasets, woop
Browse files Browse the repository at this point in the history
  • Loading branch information
dhigginbotham committed Sep 16, 2015
1 parent 2d72705 commit c432087
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .publish
Submodule .publish updated from 36264a to 134d17
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "murk",
"main": "./dist/murk.js",
"version": "0.6.0",
"version": "0.7.0",
"homepage": "https://github.com/dhigginbotham/murk",
"authors": [
"David Higginbotham <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion dist/murk.js

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

Binary file modified dist/murk.js.gz
Binary file not shown.
52 changes: 31 additions & 21 deletions examples/js/murk.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,12 @@
// as well as the current key being processed. it tries to be extremely
// light by only doing reads, and saving writes until the end.
function handleRepeat(key) {
var repeatModel, repeatElKeys, frag, processRepeats;
var repeatModel, attrs, repeatElKeys, frag, processRepeats;
if (state.model[key] instanceof Array) {
// hide our first elem, so we can use it later
if (this.style.display != 'none') this.style.display = 'none';
repeatModel = state.model[key];
attrs = attr(this);

// we keep reference of all of our repeats
// inside of state.repeats, so we always
Expand All @@ -222,7 +223,7 @@

// processes each repeat individually
processRepeats = function(repeat, i) {
var el, $key = (key + '.$' + i), newEl = false;
var el, atts, $key = (key + '.$' + i), newEl = false;

// we make a new key, out of our current key
// and setup any new elems that we might need
Expand All @@ -238,13 +239,14 @@
// are fresh, and non object things
// can be check simply like this
if (el.innerHTML != repeatModel) {
atts = attr(el);

// new els get sanitized
if (newEl) {
delete el.dataset.murk;
delete el.dataset.murkCount;
delete el.dataset.murkBound;
el.dataset.murkRepeat = $key;
atts(opts.selectorPrefix, 'rm');
atts(opts.selectorPrefix + '-count', 'rm');
atts(opts.selectorPrefix + '-bound', 'rm');
atts(opts.selectorPrefix + '-repeat', $key);
}
if (typeof repeat == 'object') {
// allows us to keep ref of new $key,
Expand All @@ -271,19 +273,26 @@
// proccesses the filters added to any
// given bound elem
function processFiltersEvent(key) {
var filters, processFilter;
if ('murkFilter' in this.dataset) {
filters = this.dataset.murkFilter;
processFilter = function(filter) {
if (state.filters.hasOwnProperty(filter) &&
state.model.hasOwnProperty(key)) {
var val = state.filters[filter].call(this, state.model[key]);
setupTextNode(this, val);
}
};
if (filters.indexOf(',') != -1) filters = filters.split(',');
if (!(filters instanceof Array)) filters = [filters];
Array.prototype.forEach.call(filters, processFilter, this);
var attrs, filters, filterMutate, processFilter;
attrs = attr(this);
if (attrs) {
filters = attrs(opts.selectorPrefix + '-filter');
filterMutate = attrs(opts.selectorPrefix + '-filter-mutate');
if (filters) {
processFilter = function(filter) {
if (state.filters.hasOwnProperty(filter) &&
state.model.hasOwnProperty(key)) {
var val = state.filters[filter].call(this, state.model[key]);
if (typeof val != 'undefined' && filterMutate) {
state.model[key] = val;
}
setupTextNode(this, val);
}
};
if (filters.indexOf(',') != -1) filters = filters.split(',');
if (!(filters instanceof Array)) filters = [filters];
Array.prototype.forEach.call(filters, processFilter, this);
}
}
}

Expand Down Expand Up @@ -316,8 +325,9 @@
// times we're interacting with our
// elems
function trackCountEvent() {
var count = ('murkCount' in this.dataset ? this.dataset.murkCount : null);
this.dataset.murkCount = (count ? parseInt(count,0)+1 : 1);
var count, attrs = attr(this);
count = attrs(opts.selectorPrefix + '-count');
attrs(opts.selectorPrefix + '-count', (count ? parseInt(count,0)+1 : 1));
}

// handles dom manipulation
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": "murk",
"version": "0.6.0",
"version": "0.7.0",
"description": "data binding in new browsers",
"main": "index.js",
"directories": {
Expand Down
52 changes: 31 additions & 21 deletions src/murk.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,12 @@
// as well as the current key being processed. it tries to be extremely
// light by only doing reads, and saving writes until the end.
function handleRepeat(key) {
var repeatModel, repeatElKeys, frag, processRepeats;
var repeatModel, attrs, repeatElKeys, frag, processRepeats;
if (state.model[key] instanceof Array) {
// hide our first elem, so we can use it later
if (this.style.display != 'none') this.style.display = 'none';
repeatModel = state.model[key];
attrs = attr(this);

// we keep reference of all of our repeats
// inside of state.repeats, so we always
Expand All @@ -222,7 +223,7 @@

// processes each repeat individually
processRepeats = function(repeat, i) {
var el, $key = (key + '.$' + i), newEl = false;
var el, atts, $key = (key + '.$' + i), newEl = false;

// we make a new key, out of our current key
// and setup any new elems that we might need
Expand All @@ -238,13 +239,14 @@
// are fresh, and non object things
// can be check simply like this
if (el.innerHTML != repeatModel) {
atts = attr(el);

// new els get sanitized
if (newEl) {
delete el.dataset.murk;
delete el.dataset.murkCount;
delete el.dataset.murkBound;
el.dataset.murkRepeat = $key;
atts(opts.selectorPrefix, 'rm');
atts(opts.selectorPrefix + '-count', 'rm');
atts(opts.selectorPrefix + '-bound', 'rm');
atts(opts.selectorPrefix + '-repeat', $key);
}
if (typeof repeat == 'object') {
// allows us to keep ref of new $key,
Expand All @@ -271,19 +273,26 @@
// proccesses the filters added to any
// given bound elem
function processFiltersEvent(key) {
var filters, processFilter;
if ('murkFilter' in this.dataset) {
filters = this.dataset.murkFilter;
processFilter = function(filter) {
if (state.filters.hasOwnProperty(filter) &&
state.model.hasOwnProperty(key)) {
var val = state.filters[filter].call(this, state.model[key]);
setupTextNode(this, val);
}
};
if (filters.indexOf(',') != -1) filters = filters.split(',');
if (!(filters instanceof Array)) filters = [filters];
Array.prototype.forEach.call(filters, processFilter, this);
var attrs, filters, filterMutate, processFilter;
attrs = attr(this);
if (attrs) {
filters = attrs(opts.selectorPrefix + '-filter');
filterMutate = attrs(opts.selectorPrefix + '-filter-mutate');
if (filters) {
processFilter = function(filter) {
if (state.filters.hasOwnProperty(filter) &&
state.model.hasOwnProperty(key)) {
var val = state.filters[filter].call(this, state.model[key]);
if (typeof val != 'undefined' && filterMutate) {
state.model[key] = val;
}
setupTextNode(this, val);
}
};
if (filters.indexOf(',') != -1) filters = filters.split(',');
if (!(filters instanceof Array)) filters = [filters];
Array.prototype.forEach.call(filters, processFilter, this);
}
}
}

Expand Down Expand Up @@ -316,8 +325,9 @@
// times we're interacting with our
// elems
function trackCountEvent() {
var count = ('murkCount' in this.dataset ? this.dataset.murkCount : null);
this.dataset.murkCount = (count ? parseInt(count,0)+1 : 1);
var count, attrs = attr(this);
count = attrs(opts.selectorPrefix + '-count');
attrs(opts.selectorPrefix + '-count', (count ? parseInt(count,0)+1 : 1));
}

// handles dom manipulation
Expand Down

0 comments on commit c432087

Please sign in to comment.