Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit354b7df

Browse files
committed
apply csp patch
1 parentd53c40a commit354b7df

File tree

12 files changed

+4793
-121
lines changed

12 files changed

+4793
-121
lines changed

‎build/grunt-tasks/build.js‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,21 @@
33
*/
44

55
module.exports=function(grunt){
6-
grunt.registerTask('build',function(){
6+
7+
grunt.registerTask('build-vendor',function(){
8+
varwebpack=require('webpack')
9+
webpack({
10+
entry:'./node_modules/notevil/index.js',
11+
output:{
12+
path:'./vendor',
13+
filename:'notevil.js',
14+
library:'notevil',
15+
libraryTarget:'commonjs2'
16+
}
17+
},this.async())
18+
})
19+
20+
grunt.registerTask('build-self',function(){
721

822
vardone=this.async()
923
varfs=require('fs')
@@ -47,4 +61,6 @@ module.exports = function (grunt) {
4761
return'\x1b[1m\x1b[34m'+str+'\x1b[39m\x1b[22m'
4862
}
4963
})
64+
65+
grunt.registerTask('build',['build-vendor','build-self'])
5066
}

‎gruntfile.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ module.exports = function (grunt) {
2424
files:[
2525
'test/unit/lib/util.js',
2626
'test/unit/lib/jquery.js',
27+
'vendor/*.js',
2728
'src/**/*.js',
2829
'test/unit/specs/**/*.js'
2930
],
3031
preprocessors:{
32+
'vendor/*.js':['commonjs'],
3133
'src/**/*.js':['commonjs'],
3234
'test/unit/specs/**/*.js':['commonjs']
3335
},
@@ -44,6 +46,7 @@ module.exports = function (grunt) {
4446
browsers:['PhantomJS'],
4547
reporters:['progress','coverage'],
4648
preprocessors:{
49+
'vendor/*.js':['commonjs'],
4750
'src/**/*.js':['commonjs','coverage'],
4851
'test/unit/specs/**/*.js':['commonjs']
4952
},

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"karma-phantomjs-launcher":"^0.2.1",
4646
"karma-safari-launcher":"^0.1.1",
4747
"karma-sauce-launcher":"^0.2.14",
48+
"notevil":"^1.0.0",
4849
"phantomjs":"^1.9.17",
4950
"semver":"^5.0.1",
5051
"shell-task":"^1.0.0",

‎src/api/child.js‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,10 @@ exports.$addChild = function (opts, BaseCtor) {
2525
varctors=context._childCtors
2626
ChildVue=ctors[BaseCtor.cid]
2727
if(!ChildVue){
28-
varoptionName=BaseCtor.options.name
29-
varclassName=optionName
30-
?_.classify(optionName)
31-
:'VueComponent'
32-
ChildVue=newFunction(
33-
'return function '+className+' (options) {'+
34-
'this.constructor = '+className+';'+
35-
'this._init(options) }'
36-
)()
28+
ChildVue=functionVueComponent(options){
29+
this.constructor=ChildVue
30+
this._init(options)
31+
}
3732
ChildVue.options=BaseCtor.options
3833
ChildVue.linker=BaseCtor.linker
3934
ChildVue.prototype=context

‎src/api/global.js‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ var cid = 1
3636
exports.extend=function(extendOptions){
3737
extendOptions=extendOptions||{}
3838
varSuper=this
39-
varSub=createClass(
40-
extendOptions.name||
41-
Super.options.name||
42-
'VueComponent'
43-
)
39+
varSub=functionVueComponent(options){
40+
_.Vue.call(this,options)
41+
}
4442
Sub.prototype=Object.create(Super.prototype)
4543
Sub.prototype.constructor=Sub
4644
Sub.cid=cid++
@@ -59,22 +57,6 @@ exports.extend = function (extendOptions) {
5957
returnSub
6058
}
6159

62-
/**
63-
* A function that returns a sub-class constructor with the
64-
* given name. This gives us much nicer output when
65-
* logging instances in the console.
66-
*
67-
*@param {String} name
68-
*@return {Function}
69-
*/
70-
71-
functioncreateClass(name){
72-
returnnewFunction(
73-
'return function '+_.classify(name)+
74-
' (options) { this._init(options) }'
75-
)()
76-
}
77-
7860
/**
7961
* Plugin system
8062
*

‎src/parsers/expression.js‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var_=require('../util')
22
varPath=require('./path')
33
varCache=require('../cache')
4+
varnotevil=require('../../vendor/notevil')
45
varexpressionCache=newCache(1000)
56

67
varallowedKeywords=
@@ -173,7 +174,13 @@ function compilePathFns (exp) {
173174

174175
functionmakeGetter(body){
175176
try{
176-
returnnewFunction('scope','return '+body+';')
177+
varfn=notevil.Function(
178+
'scope','Math',
179+
'return '+body+';'
180+
)
181+
returnfunction(scope){
182+
returnfn.call(this,scope,Math)
183+
}
177184
}catch(e){
178185
process.env.NODE_ENV!=='production'&&_.warn(
179186
'Invalid expression. '+
@@ -198,7 +205,15 @@ function makeGetter (body) {
198205

199206
functionmakeSetter(body){
200207
try{
201-
returnnewFunction('scope','value',body+'=value;')
208+
varfn=notevil.Function(
209+
'scope','value','Math',
210+
body+' = value;'
211+
)
212+
returnfunction(scope,value){
213+
try{
214+
fn.call(this,scope,value,Math)
215+
}catch(e){}
216+
}
202217
}catch(e){
203218
process.env.NODE_ENV!=='production'&&_.warn(
204219
'Invalid setter function body: '+body

‎src/parsers/path.js‎

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var_=require('../util')
22
varCache=require('../cache')
33
varpathCache=newCache(1000)
4-
varidentRE=exports.identRE=/^[$_a-zA-Z]+[\w$]*$/
4+
exports.identRE=/^[$_a-zA-Z]+[\w$]*$/
55

66
// actions
77
varAPPEND=0
@@ -229,25 +229,6 @@ function parsePath (path) {
229229
}
230230
}
231231

232-
/**
233-
* Format a accessor segment based on its type.
234-
*
235-
*@param {String} key
236-
*@return {Boolean}
237-
*/
238-
239-
functionformatAccessor(key){
240-
if(identRE.test(key)){// identifier
241-
return'.'+key
242-
}elseif(+key===key>>>0){// bracket index
243-
return'['+key+']'
244-
}elseif(key.charAt(0)==='*'){
245-
return'[o'+formatAccessor(key.slice(1))+']'
246-
}else{// bracket string
247-
return'["'+key.replace(/"/g,'\\"')+'"]'
248-
}
249-
}
250-
251232
/**
252233
* Compiles a getter function with a fixed path.
253234
* The fixed path getter supresses errors.
@@ -257,8 +238,22 @@ function formatAccessor (key) {
257238
*/
258239

259240
exports.compileGetter=function(path){
260-
varbody='return o'+path.map(formatAccessor).join('')
261-
returnnewFunction('o',body)
241+
returnfunctionget(obj){
242+
varoriginal=obj
243+
varsegment
244+
for(vari=0,l=path.length;i<l;i++){
245+
segment=path[i]
246+
if(segment.charAt(0)==='*'){
247+
segment=original[segment.slice(1)]
248+
}
249+
obj=obj[segment]
250+
if(i===l-1){
251+
returnobj
252+
}elseif(!_.isObject(obj)){
253+
return
254+
}
255+
}
256+
}
262257
}
263258

264259
/**

‎test/unit/specs/api/child_spec.js‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,4 @@ describe('Child API', function () {
6666
varchild2=vm.$addChild(null,Ctor)
6767
expect(child1.constructor).toBe(child2.constructor)
6868
})
69-
70-
it('Use proper constructor name with inherit',function(){
71-
varCtor=Vue.extend({
72-
name:'vue-test',
73-
inherit:true
74-
})
75-
varchild=vm.$addChild(null,Ctor)
76-
expect(child.constructor.toString().match(/^functionVueTest\s?\(/)).toBeTruthy()
77-
})
78-
7969
})

‎test/unit/specs/api/data_spec.js‎

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,6 @@ describe('Data API', function () {
4444
expect(hasWarned(_,'Consider pre-initializing')).toBe(true)
4545
})
4646

47-
it('$set invalid',function(){
48-
// invalid, should throw
49-
if(leftHandThrows()){
50-
// if creating a function with invalid left hand
51-
// expression throws, the exp parser will catch the
52-
// error and warn.
53-
vm.$set('c + d',1)
54-
expect(hasWarned(_,'Invalid setter function body')).toBe(true)
55-
}else{
56-
// otherwise it will throw when calling the setter.
57-
expect(function(){
58-
try{
59-
vm.$set('c + d',1)
60-
}catch(e){
61-
returntrue
62-
}
63-
}()).toBe(true)
64-
}
65-
})
66-
6747
it('$add',function(){
6848
vm._digest=jasmine.createSpy()
6949
vm.$add('c',1)
@@ -187,16 +167,3 @@ describe('Data API', function () {
187167
}
188168

189169
})
190-
191-
/**
192-
* check if creating a new Function with invalid left-hand
193-
* assignment would throw
194-
*/
195-
196-
functionleftHandThrows(){
197-
try{
198-
newFunction('a + b = 1')
199-
}catch(e){
200-
returntrue
201-
}
202-
}

‎test/unit/specs/api/global_spec.js‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ describe('Global API', function () {
1919
expect(Test.options.a).toBe(1)
2020
expect(Test.options.b).toBe(2)
2121
expect(Test.super).toBe(Vue)
22-
// function.name is not available in IE
23-
expect(Test.toString().match(/^functionTest\s?\(/)).toBeTruthy()
2422
vart=newTest({
2523
a:2
2624
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp