From 957f05da239617f00ed9dc7d83caa23ccdcbbc86 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Mon, 24 Jul 2017 15:53:29 +0300 Subject: [PATCH] fix non-extendable objects regression of 1.1.0 Closes #5650 until we figure out a less hacky solution. --- .travis.yml | 2 +- package.json | 8 ++++---- spec/karma.conf.js | 2 +- spec/suites/core/GeneralSpec.js | 6 ++++++ src/Leaflet.js | 3 +++ src/core/Util.js | 3 +++ 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 56aa74a1..740aeb33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ sudo: false language: node_js node_js: - - 4 + - node addons: artifacts: paths: diff --git a/package.json b/package.json index 04a1dbd1..77ab4c83 100644 --- a/package.json +++ b/package.json @@ -14,19 +14,19 @@ "karma-firefox-launcher": "~1.0.0", "karma-mocha": "^1.2.0", "karma-phantomjs-launcher": "^1.0.2", - "karma-rollup-plugin": "^0.2.4", + "karma-rollup-preprocessor": "^4.0.1", "karma-safari-launcher": "~1.0.0", "leafdoc": "^1.4.1", "mocha": "^3.1.0", "phantomjs-prebuilt": "^2.1.12", "prosthetic-hand": "^1.3.1", - "rollup": "^0.41.4", + "rollup": "^0.45.2", "rollup-plugin-git-version": "0.2.1", "rollup-plugin-json": "^2.1.0", - "rollup-watch": "^2.5.0", + "rollup-watch": "^4.3.1", "source-map": "^0.5.6", "ssri": "^4.1.2", - "uglify-js": "~2.7.3" + "uglify-js": "~3.0.26" }, "main": "dist/leaflet-src.js", "style": "dist/leaflet.css", diff --git a/spec/karma.conf.js b/spec/karma.conf.js index 6bd405f3..01e828bf 100644 --- a/spec/karma.conf.js +++ b/spec/karma.conf.js @@ -25,7 +25,7 @@ module.exports = function (config) { basePath: '../', plugins: [ - 'karma-rollup-plugin', + 'karma-rollup-preprocessor', 'karma-mocha', 'karma-coverage', 'karma-phantomjs-launcher', diff --git a/spec/suites/core/GeneralSpec.js b/spec/suites/core/GeneralSpec.js index c955e0ab..561d5e54 100644 --- a/spec/suites/core/GeneralSpec.js +++ b/spec/suites/core/GeneralSpec.js @@ -8,4 +8,10 @@ describe('General', function () { expect(L.noConflict()).to.eql(leaflet); }); + + describe('namespace extension', function () { + L.Util.foo = 'bar'; + + expect(L.Util.foo).to.eql('bar'); + }); }); diff --git a/src/Leaflet.js b/src/Leaflet.js index 70a067dc..1337f07e 100644 --- a/src/Leaflet.js +++ b/src/Leaflet.js @@ -33,3 +33,6 @@ export function noConflict() { // Always export us to window global (see #2364) window.L = exports; + +import {freeze} from './core/Util'; +Object.freeze = freeze; diff --git a/src/core/Util.js b/src/core/Util.js index e1d02890..12ea3b1b 100644 --- a/src/core/Util.js +++ b/src/core/Util.js @@ -4,6 +4,9 @@ * Various utility functions, used by Leaflet internally. */ +export var freeze = Object.freeze; +Object.freeze = function (obj) { return obj; }; + // @function extend(dest: Object, src?: Object): Object // Merges the properties of the `src` object (or multiple objects) into `dest` object and returns the latter. Has an `L.extend` shortcut. export function extend(dest) {