8000 Fix setting tickwidth, tickcolor, ticklen, linecolor and possibly more attributes via template by archmoj · Pull Request #4904 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Fix setting tickwidth, tickcolor, ticklen, linecolor and possibly more attributes via template #4904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 17, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add internal _coerce function
  • Loading branch information
archmoj committed Jun 8, 2020
commit 642bf285c6bdfbff3d6f72ae4352be8b06a4670d
24 changes: 17 additions & 7 deletions src/lib/coerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ exports.valObjectMeta = {
* as a convenience, returns the value it finally set
*/
exports.coerce = function(containerIn, containerOut, attributes, attribute, dflt) {
return _coerce(containerIn, containerOut, attributes, attribute, dflt).value;
};

function _coerce(containerIn, containerOut, attributes, attribute, dflt) {
var opts = nestedProperty(attributes, attribute).get();
var propIn = nestedProperty(containerIn, attribute);
var propOut = nestedProperty(containerOut, attribute);
Expand All @@ -383,7 +387,10 @@ exports.coerce = function(containerIn, containerOut, attributes, attribute, dflt
*/
if(opts.arrayOk && isArrayOrTypedArray(valIn)) {
propOut.set(valIn);
return valIn;
return {
value: valIn,
default: dflt
};
}

var coerceFunction = exports.valObjectMeta[opts.valType].coerceFunction;
Expand All @@ -397,8 +404,11 @@ exports.coerce = function(containerIn, containerOut, attributes, attribute, dflt
coerceFunction(valIn, propOut, dflt, opts);
valOut = propOut.get();
}
return valOut;
};
return {
value: valOut,
default: dflt
};
}

/**
* Variation on coerce
Expand All @@ -408,11 +418,11 @@ exports.coerce = function(containerIn, containerOut, attributes, attribute, dflt
* returns false if there is no user input.
*/
exports.coerce2 = function(containerIn, containerOut, attributes, attribute, dflt) {
var valOut = exports.coerce(containerIn, containerOut, attributes, attribute, dflt);

var attr = attributes[attribute];
var theDefault = (dflt !== undefined) ? dflt : (attr || {}).dflt;
var out = _coerce(containerIn, containerOut, attributes, attribute, dflt);
var valOut = out.value;
var theDefault = out.default;
if(
valOut !== undefined &&
theDefault !== undefined &&
theDefault !== valOut
) {
Expand Down
0