From 83e55b0c964a619b3920cbdcc30844b0c38b8449 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 5 Jul 2014 21:37:16 -0400 Subject: [PATCH] update to latest version of rcu --- bower.json | 2 +- package.json | 6 +++--- rvc.js | 50 ++++++++++++++++++++++++++++++++------------------ 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/bower.json b/bower.json index 0b4aa50..d55c33b 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "rvc", "description": "RequireJS plugin to load and optimise Ractive components", - "version": "0.1.8", + "version": "0.2.0", "author": "Rich Harris", "license": "MIT", "main": ["rvc.js"], diff --git a/package.json b/package.json index 1c46f1c..9f33ee0 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rvc", - "version": "0.1.8", + "version": "0.2.0", "description": "RequireJS plugin to load and optimise Ractive components", "main": "rvc.js", "repository": { @@ -28,7 +28,7 @@ "tosource": "~0.1.1", "jit-grunt": "~0.4.1", "requirejs": "~2.1.13", - "ractive": "~0.4.0", - "rcu": "~0.1.6" + "ractive": "~0.5.4", + "rcu": "~0.2.0" } } diff --git a/rvc.js b/rvc.js index 97eccd5..3cf0fdd 100644 --- a/rvc.js +++ b/rvc.js @@ -1,6 +1,6 @@ /* - rvc.js - v0.1.7 - 2014-06-02 + rvc.js - v0.2.0 - 2014-07-05 ========================================================== https://github.com/ractivejs/rvc @@ -205,14 +205,14 @@ define( [ 'ractive' /* - rcu (Ractive component utils) - 0.1.5 - 2014-06-02 + rcu (Ractive component utils) - 0.2.0 - 2014-07-05 ============================================================== Copyright 2014 Rich Harris and contributors Released under the MIT license. */ - var rcuamd = function() { + var rcu = function() { var Ractive; var getName = function getName( path ) { @@ -228,38 +228,51 @@ define( [ 'ractive' var parse = function( getName ) { var requirePattern = /require\s*\(\s*(?:"([^"]+)"|'([^']+)')\s*\)/g; return function parse( source ) { - var template, links, imports, scripts, script, styles, match, modules, i, item; - template = Ractive.parse( source, { + var parsed, template, links, imports, scripts, script, styles, match, modules, i, item; + parsed = Ractive.parse( source, { noStringify: true, interpolateScripts: false, interpolateStyles: false } ); + if ( parsed.v !== 1 ) { + throw new Error( 'Mismatched template version! Please ensure you are using the latest version of Ractive.js in your build process as well as in your app' ); + } links = []; scripts = []; styles = []; modules = []; // Extract certain top-level nodes from the template. We work backwards // so that we can easily splice them out as we go + template = parsed.t; i = template.length; while ( i-- ) { item = template[ i ]; if ( item && item.t === 7 ) { - if ( item.e === 'link' && ( item.a && item.a.rel[ 0 ] === 'ractive' ) ) { + if ( item.e === 'link' && ( item.a && item.a.rel === 'ractive' ) ) { links.push( template.splice( i, 1 )[ 0 ] ); } - if ( item.e === 'script' && ( !item.a || !item.a.type || item.a.type[ 0 ] === 'text/javascript' ) ) { + if ( item.e === 'script' && ( !item.a || !item.a.type || item.a.type === 'text/javascript' ) ) { scripts.push( template.splice( i, 1 )[ 0 ] ); } - if ( item.e === 'style' && ( !item.a || !item.a.type || item.a.type[ 0 ] === 'text/css' ) ) { + if ( item.e === 'style' && ( !item.a || !item.a.type || item.a.type === 'text/css' ) ) { styles.push( template.splice( i, 1 )[ 0 ] ); } } } + // Clean up template - trim whitespace left over from the removal + // of ,