From 8fb3eb33626dd35f908d848d210c984db67bf63b Mon Sep 17 00:00:00 2001 From: Vijay Menon Date: Tue, 1 Dec 2015 15:54:54 -0800 Subject: [PATCH] Fixes for exports BUG= R=jmesserly@google.com Review URL: https://codereview.chromium.org/1488273002 . --- pkg/dev_compiler/lib/runtime/dart/_utils.js | 9 +++++++-- pkg/dev_compiler/tool/input_sdk/private/utils.dart | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pkg/dev_compiler/lib/runtime/dart/_utils.js b/pkg/dev_compiler/lib/runtime/dart/_utils.js index 5dee57077110..9793464a006c 100644 --- a/pkg/dev_compiler/lib/runtime/dart/_utils.js +++ b/pkg/dev_compiler/lib/runtime/dart/_utils.js @@ -68,7 +68,12 @@ dart_library.library('dart/_utils', null, /* Imports */[ } function copyTheseProperties(to, from, names) { for (let name of names) { - defineProperty(to, name, getOwnPropertyDescriptor(from, name)); + var desc = getOwnPropertyDescriptor(from, name); + if (desc != void 0) { + defineProperty(to, name, desc); + } else { + defineLazyProperty(to, name, () => from[name]); + } } return to; } @@ -76,7 +81,7 @@ dart_library.library('dart/_utils', null, /* Imports */[ return copyTheseProperties(to, from, getOwnNamesAndSymbols(from)); } function export_(to, from, show, hide) { - if (show == void 0) { + if (show == void 0 || show.length == 0) { show = getOwnNamesAndSymbols(from); } if (hide != void 0) { diff --git a/pkg/dev_compiler/tool/input_sdk/private/utils.dart b/pkg/dev_compiler/tool/input_sdk/private/utils.dart index c4a81ea14de2..636829e79270 100644 --- a/pkg/dev_compiler/tool/input_sdk/private/utils.dart +++ b/pkg/dev_compiler/tool/input_sdk/private/utils.dart @@ -97,7 +97,12 @@ defineMemoizedGetter(obj, String name, getter) => copyTheseProperties(to, from, names) => JS('', '''((to, from, names) => { for (let name of names) { - defineProperty(to, name, getOwnPropertyDescriptor(from, name)); + var desc = getOwnPropertyDescriptor(from, name); + if (desc != void 0) { + defineProperty(to, name, desc); + } else { + defineLazyProperty(to, name, () => from[name]); + } } return to; })(#, #, #)''', to, from, names); @@ -112,7 +117,7 @@ copyProperties(to, from) => JS('', '''((to, from) => { // TODO(ochafik): Re-introduce a @JS annotation in the SDK (same as package:js) // so that this is named 'export' in JavaScript. export_(to, from, show, hide) => JS('', '''((to, from, show, hide) => { - if (show == void 0) { + if (show == void 0 || show.length == 0) { show = getOwnNamesAndSymbols(from); } if (hide != void 0) {