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
refactor coerce rename v to valIn
  • Loading branch information
archmoj committed Jun 7, 2020
commit 756a0ee4441df7eb4ad8c347c17f2018a86e086e
20 changes: 10 additions & 10 deletions src/lib/coerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,11 @@ exports.coerce = function(containerIn, containerOut, attributes, attribute, dflt
var opts = nestedProperty(attributes, attribute).get();
var propIn = nestedProperty(containerIn, attribute);
var propOut = nestedProperty(containerOut, attribute);
var v = propIn.get();
var valIn = propIn.get();

var template = containerOut._template;
if(v === undefined && template) {
v = nestedProperty(template, attribute).get();
if(valIn === undefined && template) {
valIn = nestedProperty(template, attribute).get();
// already used the template value, so short-circuit the second check
template = 0;
}
Expand All @@ -381,20 +381,20 @@ exports.coerce = function(containerIn, containerOut, attributes, attribute, dflt
* individual form (eg. some array vals can be numbers, even if the
* single values must be color strings)
*/
if(opts.arrayOk && isArrayOrTypedArray(v)) {
propOut.set(v);
return v;
if(opts.arrayOk && isArrayOrTypedArray(valIn)) {
propOut.set(valIn);
return valIn;
}

var coerceFunction = exports.valObjectMeta[opts.valType].coerceFunction;
coerceFunction(v, propOut, dflt, opts);
coerceFunction(valIn, propOut, dflt, opts);

var out = propOut.get();
// in case v was provided but invalid, try the template again so it still
// overrides the regular default
if(template && out === dflt && !validate(v, opts)) {
v = nestedProperty(template, attribute).get();
coerceFunction(v, propOut, dflt, opts);
if(template && out === dflt && !validate(valIn, opts)) {
valIn = nestedProperty(template, attribute).get();
coerceFunction(valIn, propOut, dflt, opts);
out = propOut.get();
}
return out;
Expand Down
0