Skip to content

Commit

Permalink
Merge 2b8fdd7 into f0e6cc7
Browse files Browse the repository at this point in the history
  • Loading branch information
tbranyen committed Jun 13, 2016
2 parents f0e6cc7 + 2b8fdd7 commit b2be64f
Show file tree
Hide file tree
Showing 35 changed files with 4,811 additions and 2,858 deletions.
2,166 changes: 2,166 additions & 0 deletions dist/diffhtml-runtime.js

Large diffs are not rendered by default.

3,029 changes: 1,449 additions & 1,580 deletions dist/diffhtml.js

Large diffs are not rendered by default.

82 changes: 0 additions & 82 deletions lib/element/make.js

This file was deleted.

25 changes: 0 additions & 25 deletions lib/errors.js

This file was deleted.

67 changes: 0 additions & 67 deletions lib/html.js

This file was deleted.

71 changes: 24 additions & 47 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import patchNode from './node/patch';
import releaseNode from './node/release';
import makeNode from './node/make';
import { TreeCache } from './node/tree';
import { states } from './transitions';
import createTransaction from './node/transaction';
import { states as transitionStates } from './util/transitions';

// Export the custom Error constructors so that instanceof checks can be made
// by those publicly consuming this library.
export { TransitionStateError, DOMException } from './errors';
import { TransitionStateError, DOMException } from './errors';
// Export the HTML tagged template helper util.
export { html } from './util/tagged-template';
import { html } from './util/tagged-template';

// Export the HTML tagged template helper.
export { html } from './html';
import { html } from './html';
// Export the DOM Node release method.
export { default as release } from './node/release';

// Export the VTree/Attribute helpers.
export { createElement, createAttribute } from './util/transform';
// Export the Virtual Tree Element/Attribute helpers.
export { createElement, createAttribute } from './tree/helpers';

/**
* Used to diff the outerHTML contents of the passed element with the markup
Expand All @@ -27,7 +22,7 @@ export { createElement, createAttribute } from './util/transform';
*/
export function outerHTML(element, markup='', options={}) {
options.inner = false;
patchNode(element, markup, options);
createTransaction(element, markup, options);
}

/**
Expand All @@ -41,7 +36,7 @@ export function outerHTML(element, markup='', options={}) {
*/
export function innerHTML(element, markup='', options={}) {
options.inner = true;
patchNode(element, markup, options);
createTransaction(element, markup, options);
}

/**
Expand All @@ -54,17 +49,7 @@ export function innerHTML(element, markup='', options={}) {
* @param options={}
*/
export function element(element, newElement, options={}) {
patchNode(element, newElement, options);
}

/**
* Releases the memory allocated to this element. Useful for cleaning up
* components when removed in tests and applications.
*
* @param element
*/
export function release(element) {
releaseNode(element);
createTransaction(element, newElement, options);
}

/**
Expand Down Expand Up @@ -93,19 +78,19 @@ export function release(element) {
*/
export function addTransitionState(state, callback) {
if (!state) {
throw new TransitionStateError('Missing transition state name');
throw new Error('Missing transition state name');
}

if (!callback) {
throw new TransitionStateError('Missing transition state callback');
throw new Error('Missing transition state callback');
}

// Not a valid state name.
if (Object.keys(states).indexOf(state) === -1) {
throw new TransitionStateError('Invalid state name: ' + state);
if (Object.keys(transitionStates).indexOf(state) === -1) {
throw new Error('Invalid state name: ' + state);
}

states[state].push(callback);
transitionStates[state].push(callback);
}

/**
Expand All @@ -121,20 +106,20 @@ export function addTransitionState(state, callback) {
*/
export function removeTransitionState(state, callback) {
if (!callback && state) {
states[state].length = 0;
transitionStates[state].length = 0;
}
else if (state && callback) {
// Not a valid state name.
if (Object.keys(states).indexOf(state) === -1) {
throw new TransitionStateError('Invalid state name ' + state);
if (Object.keys(transitionStates).indexOf(state) === -1) {
throw new Error('Invalid state name ' + state);
}

let index = states[state].indexOf(callback);
states[state].splice(index, 1);
let index = transitionStates[state].indexOf(callback);
transitionStates[state].splice(index, 1);
}
else {
for (let state in states) {
states[state].length = 0;
for (let state in transitionStates) {
transitionStates[state].length = 0;
}
}
}
Expand All @@ -153,14 +138,6 @@ export function enableProllyfill() {
value: html
});

// Exposes the `TransitionStateError` constructor globally so that developers
// can instanceof check exception errors.
Object.defineProperty(window, 'TransitionStateError', {
configurable: true,

value: TransitionStateError
});

// Allows a developer to add transition state callbacks.
Object.defineProperty(document, 'addTransitionState', {
configurable: true,
Expand Down
Loading

0 comments on commit b2be64f

Please sign in to comment.