Comparing version 1.0.0-alpha4 to 1.0.0-alpha5
@@ -36,3 +36,3 @@ var stringifySyntax = require('./stringify'); | ||
error.rawMessage = message; | ||
error.syntax = stringifySyntax(syntax); | ||
error.syntax = syntax ? stringifySyntax(syntax) : '<generic>'; | ||
error.css = css; | ||
@@ -39,0 +39,0 @@ error.line = badNode && badNode.info ? badNode.info.line : 1; |
@@ -23,2 +23,22 @@ var MatchError = require('./error').MatchError; | ||
function matchSyntax(dictionary, syntax, value) { | ||
var result = syntax.match(value.sequence.head); | ||
if (!result || !result.match) { | ||
result = match(dictionary, dictionary.valueCommonSyntax, value.sequence.head); | ||
if (!result || !result.match) { | ||
dictionary.lastMatchError = MatchError('Mismatch', syntax.syntax, value, result.next); | ||
return null; | ||
} | ||
} | ||
if (result.next) { | ||
dictionary.lastMatchError = MatchError('Uncomplete match', syntax.syntax, value, result.next); | ||
return null; | ||
} | ||
dictionary.lastMatchError = null; | ||
return result.match; | ||
} | ||
var Syntax = function(syntax) { | ||
@@ -85,2 +105,6 @@ this.generic = false; | ||
match: function(propertyName, value) { | ||
console.warn('Syntax#match() method is deprecated. Please, use Syntax#matchProperty() or Syntax#matchType() instead'); | ||
return this.matchProperty(propertyName, value); | ||
}, | ||
matchProperty: function(propertyName, value) { | ||
var property = names.property(propertyName); | ||
@@ -90,31 +114,19 @@ var propertySyntax = property.vendor | ||
: this.getProperty(property.name); | ||
var result; | ||
// console.log(JSON.stringify(propertySyntax.syntax, null, 4)); | ||
// console.log(JSON.stringify(value, null, 4)); | ||
// console.log('-----'); | ||
// debugger; | ||
if (!propertySyntax) { | ||
this.lastMatchError = Error('Unknown property: ' + propertyName); | ||
this.lastMatchError = new Error('Unknown property for syntax match: ' + propertyName); | ||
return null; | ||
} | ||
result = propertySyntax.match(value.sequence.head); | ||
return matchSyntax(this, propertySyntax, value); | ||
}, | ||
matchType: function(typeName, value) { | ||
var typeSyntax = this.getType(typeName); | ||
if (!result || !result.match) { | ||
result = match(this, this.valueCommonSyntax, value.sequence.head); | ||
if (!result || !result.match) { | ||
this.lastMatchError = MatchError('Mismatch', propertySyntax.syntax, value, result.next); | ||
return null; | ||
} | ||
} | ||
if (result.next) { | ||
this.lastMatchError = MatchError('Uncomplete match', propertySyntax.syntax, value, result.next); | ||
if (!typeSyntax) { | ||
this.lastMatchError = new Error('Unknown type for syntax match: ' + typeName); | ||
return null; | ||
} | ||
this.lastMatchError = null; | ||
return result.match; | ||
return matchSyntax(this, typeSyntax, value); | ||
}, | ||
@@ -121,0 +133,0 @@ |
{ | ||
"name": "css-tree", | ||
"version": "1.0.0-alpha4", | ||
"version": "1.0.0-alpha5", | ||
"description": "Detailed CSS parser", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
555700
13041