-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
198 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,36 @@ | ||
'use strict'; | ||
|
||
var cloneElement = require('react').cloneElement; | ||
var transformComponentStatic = require('./util/transformComponentStatic'); | ||
var transformComponentDynamic = require('./util/transformComponentDynamic'); | ||
|
||
exports.addon = function (renderer) { | ||
var transformStatic = function (prototype, styles, block) { | ||
var render_ = prototype.render; | ||
var className = ''; | ||
|
||
prototype.render = function() { | ||
var element = render_.call(this); | ||
|
||
if (element) { | ||
if (!className) { | ||
className = renderer.rule(styles, block); | ||
} | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
element.props.className = (element.props.className || '') + className; | ||
} else { | ||
element = cloneElement(element, { | ||
className: (element.props.className || '') + className, | ||
}); | ||
} | ||
} | ||
if (process.env.NODE_ENV !== 'production') { | ||
require('./__dev__/warnOnMissingDependencies')('css', renderer, ['rule', 'cache']); | ||
} | ||
|
||
return element; | ||
}; | ||
}; | ||
renderer.css = function (a, b) { | ||
var isComponent = a && a.prototype && a.prototype.render; | ||
|
||
/* | ||
var transformDynamic = function (prototype, dynamicTemplate) { | ||
var render_ = prototype.render; | ||
prototype.render = function () { | ||
var element = render_.apply(this, arguments); | ||
var props = element.props; | ||
var className = | ||
(props.className || '') + | ||
renderer.render(this.constructor, this, this[$$el], dynamicTemplate(this)); | ||
if (process.env.NODE_ENV === 'production') { | ||
element.ref = ref; | ||
props.className = className; | ||
return element; | ||
} | ||
// Static class decorator. | ||
if (isComponent) { | ||
if (a.css) transformComponentStatic(renderer, a.prototype, a.css); | ||
|
||
return cloneElement(element, Object.assign({}, props, {ref: ref, className: className}), props.children); | ||
}; | ||
}; | ||
*/ | ||
return a; | ||
} | ||
|
||
renderer.css = function (a, b) { | ||
return function (Klass) { | ||
var block = b || Klass.displayName || Klass.name; | ||
var prototype = Klass.prototype; | ||
return function (instanceOrComp, key, descriptor) { | ||
if (typeof key === 'string') { | ||
// .render() method decorator | ||
var Comp = instanceOrComp.constructor; | ||
|
||
transformComponentDynamic(renderer, Comp, a); | ||
descriptor.value = Comp.prototype.render; | ||
|
||
return descriptor; | ||
} | ||
|
||
transformStatic(prototype, a, block); | ||
// Class decorator | ||
transformComponentStatic(renderer, instanceOrComp.prototype, a, b); | ||
}; | ||
}; | ||
}; |
Oops, something went wrong.