From 6a3849bf71c047ab414ddc18af9c4361c067a352 Mon Sep 17 00:00:00 2001 From: Mathis Neumann <mathis@simpletechs.net> Date: Thu, 23 Jun 2016 16:35:26 +0200 Subject: [PATCH] fix cose-bilkent by making embers native prototype enhancements not enumerable --- app/app.js | 18 ++++++++++++++++++ app/components/architecture-viewer.js | 4 ++-- config/environment.js | 4 +++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/app.js b/app/app.js index 831ad61..7839564 100644 --- a/app/app.js +++ b/app/app.js @@ -7,6 +7,11 @@ let App; Ember.MODEL_FACTORY_INJECTIONS = true; + +avoidEnumerableNativeExtensions(Array.prototype); +avoidEnumerableNativeExtensions(Function.prototype); +avoidEnumerableNativeExtensions(String.prototype); + App = Ember.Application.extend({ modulePrefix: config.modulePrefix, podModulePrefix: config.podModulePrefix, @@ -16,3 +21,16 @@ App = Ember.Application.extend({ loadInitializers(App, config.modulePrefix); export default App; + +// ember (via ember-runtime) sets native prototype enhancements like .property/.observer, but as enumerable +// we need to fix enumerability since it breaks cose-bilkent and sometimes cytoscape +function avoidEnumerableNativeExtensions(proto) { + Object.keys(proto) // already gets all enumerables, no need to filter + .map(key => { + return { key, descriptor: Object.getOwnPropertyDescriptor(proto, key) }; + }) + .forEach(obj => { + obj.descriptor.enumerable = false; + Object.defineProperty(proto, obj.key, obj.descriptor); + }); +} \ No newline at end of file diff --git a/app/components/architecture-viewer.js b/app/components/architecture-viewer.js index 060be55..d84afde 100644 --- a/app/components/architecture-viewer.js +++ b/app/components/architecture-viewer.js @@ -4,12 +4,12 @@ import Themes from './architecture-visualisation-cytoscape/themes'; export default Ember.Component.extend({ graph: null, entityDetails: null, - layoutAlgorithm: 'cose', + layoutAlgorithm: 'cose-bilkent', theme: Themes[Object.keys(Themes)[0]], // first theme themes: Object.keys(Themes), layoutAlgorithms: [ 'cose', - //'cose-bilkent', // broken - see https://github.com/cytoscape/cytoscape.js-cose-bilkent/issues/18 + 'cose-bilkent', 'cola', 'grid', 'concentric', diff --git a/config/environment.js b/config/environment.js index 688e1c0..c40c6dd 100644 --- a/config/environment.js +++ b/config/environment.js @@ -11,6 +11,7 @@ module.exports = function(environment) { // Here you can enable experimental features on an ember canary build // e.g. 'with-controller': true } + //EXTEND_PROTOTYPES: true // (true is default) See avoidEnumerableNativeExtensions in app.js }, APP: { @@ -19,6 +20,7 @@ module.exports = function(environment) { } }; + if (environment === 'development') { // ENV.APP.LOG_RESOLVER = true; // ENV.APP.LOG_ACTIVE_GENERATION = true; @@ -44,4 +46,4 @@ module.exports = function(environment) { } return ENV; -}; +}; \ No newline at end of file -- GitLab