[Pkg-javascript-commits] [node-cssstyle] 34/39: Load property definitions as they are needed

Wolfgang Borgert debacle at moszumanska.debian.org
Sat Sep 20 20:22:37 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to branch master
in repository node-cssstyle.

commit 460b8eb7b4b39aeea6a72894df6674442a4a982b
Author: Matthew Crinklaw-Vogt <mlaw at fb.com>
Date:   Mon May 19 12:53:24 2014 -0700

    Load property definitions as they are needed
---
 lib/CSSStyleDeclaration.js | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/lib/CSSStyleDeclaration.js b/lib/CSSStyleDeclaration.js
index e83b6b7..36f3cf0 100644
--- a/lib/CSSStyleDeclaration.js
+++ b/lib/CSSStyleDeclaration.js
@@ -199,10 +199,26 @@ property_files.forEach(function (property) {
     if (property.substr(-3) === '.js') {
         property = path.basename(property, '.js');
         dashed = camelToDashed(property);
-        definition = require('./properties/' + property).definition;
-        Object.defineProperty(CSSStyleDeclaration.prototype, property, definition);
-        Object.defineProperty(CSSStyleDeclaration.prototype, dashed, definition);
+        Object.defineProperty(CSSStyleDeclaration.prototype, property, new LazyDefinition(property, './properties/' + property));
+        Object.defineProperty(CSSStyleDeclaration.prototype, dashed, new LazyDefinition(property, './properties/' + property));
     }
 });
 
+function LazyDefinition(property, modulePath) {
+  this.get = function() {
+    var definition = require(modulePath).definition;
+    Object.defineProperty(this, property, definition);
+    return this[property];
+  };
+
+  this.set = function(v) {
+    var definition = require(modulePath).definition;
+    Object.defineProperty(this, property, definition);
+    this[property] = v;
+  };
+
+  this.enumerable = true;
+  this.configurable = true;
+}
+
 exports.CSSStyleDeclaration = CSSStyleDeclaration;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-cssstyle.git



More information about the Pkg-javascript-commits mailing list