Skip to content

Commit

Permalink
refactor: add flags correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrsh committed Dec 17, 2017
1 parent 5dccf1d commit 597756c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
12 changes: 11 additions & 1 deletion dist/moon.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@

// Data Flags
var FLAG_SVG = 1;
var FLAG_STATIC = 1 << 1;

// Trim Whitespace
var trimWhitespace = function(value) {
Expand Down Expand Up @@ -970,6 +971,15 @@
return root.children[0];
}

var generateNodeFlag = function(data, flag) {
var flags = data.flags;
if(flags === undefined) {
data.flags = flag;
} else {
data.flags = flags | flag;
}
}

var generateStaticNode = function(nodeOutput, staticNodes) {
var staticNodesLength = staticNodes.length;
staticNodes[staticNodesLength] = nodeOutput;
Expand Down Expand Up @@ -999,7 +1009,7 @@

// Mark SVG elements
if(SVG_ELEMENTS.indexOf(type) !== -1) {
data.flags = data.flags | FLAG_SVG;
generateNodeFlag(data, FLAG_SVG);
}

// Generate props
Expand Down
2 changes: 1 addition & 1 deletion dist/moon.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/compiler/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const SVG_ELEMENTS = ["animate", "circle", "clippath", "cursor", "defs", "desc",

// Data Flags
const FLAG_SVG = 1;
const FLAG_STATIC = 1 << 1;

// Trim Whitespace
const trimWhitespace = function(value) {
Expand Down
11 changes: 10 additions & 1 deletion src/compiler/generator.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
const generateNodeFlag = function(data, flag) {
const flags = data.flags;
if(flags === undefined) {
data.flags = flag;
} else {
data.flags = flags | flag;
}
}

const generateStaticNode = function(nodeOutput, staticNodes) {
const staticNodesLength = staticNodes.length;
staticNodes[staticNodesLength] = nodeOutput;
Expand Down Expand Up @@ -27,7 +36,7 @@ const generateNode = function(node, parentNode, state) {

// Mark SVG elements
if(SVG_ELEMENTS.indexOf(type) !== -1) {
data.flags = data.flags | FLAG_SVG;
generateNodeFlag(data, FLAG_SVG);
}

// Generate props
Expand Down

0 comments on commit 597756c

Please sign in to comment.