Skip to content

Commit ad909f1

Browse files
committed
Merge branch 'master' into production
2 parents de1b33d + 67fa4fd commit ad909f1

File tree

6 files changed

+42
-12
lines changed

6 files changed

+42
-12
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "tui-code-snippet",
3-
"version": "1.2.8",
3+
"version": "1.2.9",
44
"description": "TOAST UI Utility: CodeSnippet",
55
"main": "dist/tui-code-snippet.js",
66
"scripts": {
77
"test": "karma start --no-single-run",
88
"test:ne": "KARMA_SERVER=ne karma start",
9-
"bundle": "webpack && webpack -p",
9+
"bundle": "webpack & webpack -p --screw-ie8=false",
1010
"cpy-dist2doc": "mkdir -p doc/dist && cp -f -r dist doc",
1111
"doc": "jsdoc -c jsdoc.conf.json && npm run cpy-dist2doc"
1212
},

src/js/collection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function forEachOwnProperties(obj, iteratee, context) {
108108
* });
109109
* alert(sum); // 6
110110
*
111-
* // In case of Array-like object
111+
* // In case of Array-like object
112112
* var array = Array.prototype.slice.call(arrayLike); // change to array
113113
* util.forEach(array, function(value){
114114
* sum += value;

src/js/defineClass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var extend = require('./object').extend;
4242
* var Child = util.defineClass(Parent, {
4343
* childMethod: function() {}
4444
* });
45-
*
45+
*
4646
* Parent.staticMethod();
4747
*
4848
* var parentInstance = new Parent();

src/js/object.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,17 +252,19 @@ function isSameObject(x, y) { // eslint-disable-line complexity
252252
function pick(obj, paths) { // eslint-disable-line no-unused-vars
253253
var args = arguments;
254254
var target = args[0];
255+
var i = 1;
255256
var length = args.length;
256-
var i;
257-
try {
258-
for (i = 1; i < length; i += 1) {
259-
target = target[args[i]];
257+
258+
for (; i < length; i += 1) {
259+
if (type.isUndefined(target) ||
260+
type.isNull(target)) {
261+
return;
260262
}
261263

262-
return target;
263-
} catch (e) {
264-
return;// eslint-disable-line consistent-return, no-useless-return
264+
target = target[args[i]];
265265
}
266+
267+
return target; // eslint-disable-line consistent-return
266268
}
267269

268270
module.exports = {

test/object.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ describe('object', function() {
128128
expect(tui.util.pick(o2)).toBeNull();
129129
expect(tui.util.pick(o2, 'key1')).toBeUndefined();
130130
expect(tui.util.pick(o2, 'key1', 'key2')).toBeUndefined();
131+
expect(tui.util.pick(o2, 'valueOf')).toBeUndefined();
132+
expect(tui.util.pick(o2, 'toString')).toBeUndefined();
131133

132134
expect(tui.util.pick(1)).toBe(1);
133135
expect(tui.util.pick('key1')).toBe('key1');
@@ -136,22 +138,31 @@ describe('object', function() {
136138
it('Object 인 경우', function() {
137139
var obj = {
138140
'key1': 1,
141+
'key2': null,
139142
'nested': {
140143
'key1': 11,
144+
'key2': null,
141145
'nested': {
142146
'key1': 21
143147
}
144148
}
145149
};
146150

147151
expect(tui.util.pick(obj, 'key1')).toBe(1);
152+
expect(tui.util.pick(obj, 'key1', 'notFound')).toBeUndefined();
153+
148154
expect(tui.util.pick(obj, 'nested')).toEqual(obj.nested);
149155
expect(tui.util.pick(obj, 'nested', 'key1')).toBe(11);
150156
expect(tui.util.pick(obj, 'nested', 'nested')).toBe(obj.nested.nested);
151157
expect(tui.util.pick(obj, 'nested', 'nested', 'key1')).toBe(21);
152158

153159
expect(tui.util.pick(obj, 'notFound')).toBeUndefined();
154160
expect(tui.util.pick(obj, 'notFound', 'notFound')).toBeUndefined();
161+
162+
expect(tui.util.pick(obj, 'key2')).toBeNull();
163+
expect(tui.util.pick(obj, 'key2', 'key2')).toBeUndefined();
164+
expect(tui.util.pick(obj, 'key2', 'valueOf')).toBeUndefined();
165+
expect(tui.util.pick(obj, 'nested', 'key2')).toBeNull();
155166
});
156167

157168
it('배열인 경우', function() {

webpack.config.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Configs file for bundling
3+
* @author NHN Ent. FE Development Lab <dl_javascript@nhnent.com>
4+
*/
5+
16
'use strict';
27

38
var pkg = require('./package.json');
@@ -7,6 +12,12 @@ var SafeUmdPlugin = require('safe-umd-webpack-plugin');
712

813
var isProduction = process.argv.indexOf('-p') > -1;
914

15+
var uglifyJsPlugin = new webpack.optimize.UglifyJsPlugin({
16+
compress: {
17+
'properties': false
18+
}
19+
});
20+
1021
var FILENAME = pkg.name + (isProduction ? '.min.js' : '.js');
1122
var BANNER = [
1223
FILENAME,
@@ -15,7 +26,7 @@ var BANNER = [
1526
'@license ' + pkg.license
1627
].join('\n');
1728

18-
module.exports = {
29+
var config = {
1930
eslint: {
2031
failOnError: isProduction
2132
},
@@ -41,3 +52,9 @@ module.exports = {
4152
new webpack.BannerPlugin(BANNER)
4253
]
4354
};
55+
56+
if (isProduction) {
57+
config.plugins.push(uglifyJsPlugin);
58+
}
59+
60+
module.exports = config;

0 commit comments

Comments
 (0)