Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
A few bug fixes
Browse files Browse the repository at this point in the history
Ugh, already up to 0.2.3 :'(

Fix config parsing
Fixes #26
  • Loading branch information
dfreedm committed Apr 1, 2014
1 parent f21125e commit e86d845
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 15 deletions.
5 changes: 3 additions & 2 deletions lib/optparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var DEFAULT = 'vulcanized.html';

// validate options with boolean return
function processOptions(options, callback) {
excludes = {
var excludes = {
imports: [ABS_URL],
scripts: [ABS_URL],
styles: [ABS_URL]
Expand All @@ -37,7 +37,7 @@ function processOptions(options, callback) {
return callback('Malformed config JSON!');
}
if (config.excludes) {
var e = options.excludes;
var e = config.excludes;
try {
if (e.imports) {
e.imports.forEach(function(r) {
Expand All @@ -59,6 +59,7 @@ function processOptions(options, callback) {
}
}
}
options.excludes = excludes;

if (!options.output) {
options.output = path.resolve(path.dirname(options.input), DEFAULT);
Expand Down
7 changes: 1 addition & 6 deletions lib/pathresolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@

var path = require('path');
var constants = require('./constants.js');

// directly update the textnode child of <style>
// equivalent to <style>.textContent
function setTextContent(node, text) {
node[0].children[0].data = text;
}
var setTextContent = require('./utils.js').setTextContent;

function resolvePaths($, input, output) {
var assetPath = path.relative(output, input);
Expand Down
24 changes: 24 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2013 The Polymer Authors. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/

module.exports = {
// directly update the textnode child of <style>
// equivalent to <style>.textContent
setTextContent: function(node, text) {
var child = node[0].children[0];
if (child) {
child.data = text;
} else {
node[0].children[0] = {
data: text,
type: 'text',
next: null,
prev: null,
parent: node[0]
};
}
}
};
11 changes: 5 additions & 6 deletions lib/vulcan.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var url = require('url');
var constants = require('./constants.js');
var optparser = require('./optparser.js');
var pathresolver = require('./pathresolver');
var utils = require('./utils');

var read = {};
var options = {};
Expand All @@ -37,21 +38,19 @@ function exclude(regexes, href) {
}

function excludeImport(href) {
return exclude(excludes.imports, href);
return exclude(options.excludes.imports, href);
}

function excludeScript(href) {
return exclude(excludes.scripts, href);
return exclude(options.excludes.scripts, href);
}

function excludeStyle(href) {
return exclude(excludes.styles, href);
return exclude(options.excludes.styles, href);
}

// directly update the textnode child of <style>
// equivalent to <style>.textContent
function setTextContent(node, text) {
node[0].children[0].data = text;
utils.setTextContent(node, text);
}

function readFile(file) {
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": "vulcanize",
"version": "0.2.2",
"version": "0.2.3",
"description": "Process Web Components into one output file",
"main": "lib/vulcan.js",
"bin": {
Expand Down
Empty file added test/empty.css
Empty file.
1 change: 1 addition & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<script src="bower_components/platform/platform.js"></script>
<link rel="import" href="absolutes.html">
<link rel="import" href="import-test.html" />
<link rel="stylesheet" href="empty.css">
</head>
<body>
<x-import>Hello Import!</x-import>
Expand Down

0 comments on commit e86d845

Please sign in to comment.