Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Rte helpers fallback class #294

Merged
merged 3 commits into from
Sep 27, 2017
Merged
Changes from 2 commits
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
8 changes: 6 additions & 2 deletions packages/slate-theme/src/scripts/slate/rte.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ slate.rte = {
* @param {string} options.tableWrapperClass - table wrapper class name
*/
wrapTable: function(options) {
options.$tables.wrap('<div class="' + options.tableWrapperClass + '"></div>');
var tableWrapperClass = typeof options.tableWrapperClass !== 'string' ? '' : options.tableWrapperClass;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If some passes 1234 then would result in a empty string, not '1234'. Is this okay? I'm on the fence.

Copy link
Contributor Author

@NathanPJF NathanPJF Sep 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair concern. I can change it back to checking typeof undefined and then outputting the value always as a string.

Regarding the integer class names: Having class names that start with a number requires some work arounds to function in a stylesheet - quick codepen here. But those workarounds exist, so I shouldn't discount it.


options.$tables.wrap('<div class="' + tableWrapperClass + '"></div>');
},

/**
Expand All @@ -26,9 +28,11 @@ slate.rte = {
* @param {string} options.iframeWrapperClass - class name used on the wrapping div
*/
wrapIframe: function(options) {
var iframeWrapperClass = typeof options.iframeWrapperClass !== 'string' ? '' : options.iframeWrapperClass;

options.$iframes.each(function() {
// Add wrapper to make video responsive
$(this).wrap('<div class="' + options.iframeWrapperClass + '"></div>');
$(this).wrap('<div class="' + iframeWrapperClass + '"></div>');

// Re-set the src attribute on each iframe after page load
// for Chrome's "incorrect iFrame content on 'back'" bug.
Expand Down