Skip to content

Commit

Permalink
Merge branch 'pass-entry'
Browse files Browse the repository at this point in the history
  • Loading branch information
army8735 committed Jun 25, 2014
2 parents aff0500 + c61f5d1 commit 648805c
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 7 deletions.
11 changes: 10 additions & 1 deletion dist/seajs-combo-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var comboHash = data.comboHash = {}
var comboSyntax = ["??", ","]
var comboMaxLength = 2000
var comboExcludes
var comboSuffix


seajs.on("load", setComboHash)
Expand All @@ -25,6 +26,7 @@ function setComboHash(uris) {

data.comboSyntax && (comboSyntax = data.comboSyntax)
data.comboMaxLength && (comboMaxLength = data.comboMaxLength)
data.comboSuffix && (comboSuffix = data.comboSuffix)

comboExcludes = data.comboExcludes
var needComboUris = []
Expand Down Expand Up @@ -226,7 +228,14 @@ function paths2hash(paths) {
}

function setHash(root, files) {
var comboPath = root + comboSyntax[0] + files.join(comboSyntax[1])
var copy = []
for (var i = 0, len = files.length; i < len; i++) {
copy[i] = files[i].replace(/\?.*$/, '')
}
var comboPath = root + comboSyntax[0] + copy.join(comboSyntax[1])
if(comboSuffix) {
comboPath += comboSuffix
}
var exceedMax = comboPath.length > comboMaxLength

// http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url
Expand Down
2 changes: 1 addition & 1 deletion dist/seajs-combo.js

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

11 changes: 10 additions & 1 deletion src/seajs-combo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var comboHash = data.comboHash = {}
var comboSyntax = ["??", ","]
var comboMaxLength = 2000
var comboExcludes
var comboSuffix


seajs.on("load", setComboHash)
Expand All @@ -24,6 +25,7 @@ function setComboHash(uris) {

data.comboSyntax && (comboSyntax = data.comboSyntax)
data.comboMaxLength && (comboMaxLength = data.comboMaxLength)
data.comboSuffix && (comboSuffix = data.comboSuffix)

comboExcludes = data.comboExcludes
var needComboUris = []
Expand Down Expand Up @@ -225,7 +227,14 @@ function paths2hash(paths) {
}

function setHash(root, files) {
var comboPath = root + comboSyntax[0] + files.join(comboSyntax[1])
var copy = []
for (var i = 0, len = files.length; i < len; i++) {
copy[i] = files[i].replace(/\?.*$/, '')
}
var comboPath = root + comboSyntax[0] + copy.join(comboSyntax[1])
if(comboSuffix) {
comboPath += comboSuffix
}
var exceedMax = comboPath.length > comboMaxLength

// http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/combo-map/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ define(function(require) {

test.assert(a.name == 'a', a.name)
test.assert(b.name == 'b', b.name)
test.assert(c === null, 'return null when c is not found')
test.assert(c === void 0, 'return undefined when c is not found' + c)

test.next()

Expand Down
6 changes: 3 additions & 3 deletions tests/spec/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=0">
<title>test</title>
<script src="http://assets.spmjs.org/seajs/seajs/2.1.1/sea.js"></script>
<script src="http://assets.spmjs.org/seajs/seajs-css/1.0.3/seajs-css.js"></script>
<script src="https://raw.githubusercontent.com/seajs/seajs/master/dist/sea-debug.js"></script>
<script src="https://raw.githubusercontent.com/seajs/seajs-css/master/dist/seajs-css.js"></script>
</head>
<body>
<div id="out"></div>
Expand All @@ -14,7 +14,7 @@
// seajs.data.preload.length = 0

seajs.use(['../test'], function(test) {
test.run(['combo', 'combo-map'])
test.run(['combo', 'combo-map', 'timestamp'])
})

</script>
Expand Down
2 changes: 2 additions & 0 deletions tests/spec/timestamp/a.js,b.js,c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
define('a', [], { name: 'a' })
define('b', [], { name: 'b' })
25 changes: 25 additions & 0 deletions tests/spec/timestamp/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
seajs.config({
base: './timestamp/'
})

define(function(require) {

var test = require('../../test')

seajs.use('../../dist/seajs-combo', function() {
seajs.config({
comboSyntax: ['', ','],
comboSuffix: '?1',
map: [
[/^(.*)$/, '$1?1']
]
})
seajs.use(['a', 'b', 'c'], function(a, b, c) {
test.assert(a.name == 'a', a.name)
test.assert(b.name == 'b', b.name)
test.assert(c === void 0, 'return undefined when c is not found' + c)

test.next()
})
});
});

0 comments on commit 648805c

Please sign in to comment.